Changed formatting to have bracing on a new line
This commit is contained in:
parent
e5eddd6c45
commit
e48eedb874
189 changed files with 6092 additions and 4041 deletions
|
@ -7,22 +7,26 @@ import net.minecraftforge.fml.common.registry.GameData;
|
|||
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
public class BlockStack {
|
||||
public class BlockStack
|
||||
{
|
||||
|
||||
private final Block block;
|
||||
private final int meta;
|
||||
|
||||
public BlockStack(Block block, int meta) {
|
||||
public BlockStack(Block block, int meta)
|
||||
{
|
||||
this.block = block;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public BlockStack(Block block) {
|
||||
public BlockStack(Block block)
|
||||
{
|
||||
this(block, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public String toString()
|
||||
{
|
||||
return GameData.getBlockRegistry().getNameForObject(block) + ":" + meta;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,12 +8,14 @@ import net.minecraft.util.DamageSource;
|
|||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
public class BloodMagicAPI {
|
||||
public class BloodMagicAPI
|
||||
{
|
||||
|
||||
public static final String ORB = "ItemBloodOrb";
|
||||
public static final String SCRIBE = "ItemInscriptionTool";
|
||||
|
||||
@Getter @Setter
|
||||
@Getter
|
||||
@Setter
|
||||
private static boolean loggingEnabled;
|
||||
|
||||
@Getter
|
||||
|
@ -23,16 +25,20 @@ public class BloodMagicAPI {
|
|||
private static DamageSource damageSource = new DamageSourceBloodMagic();
|
||||
|
||||
/**
|
||||
* Used to obtain Items from BloodMagic. Use the constants above for common items in case internal names
|
||||
* change.
|
||||
*
|
||||
* @param name - The registered name of the item. Usually the same as the class name.
|
||||
* Used to obtain Items from BloodMagic. Use the constants above for common
|
||||
* items in case internal names change.
|
||||
*
|
||||
* @param name
|
||||
* - The registered name of the item. Usually the same as the
|
||||
* class name.
|
||||
* @return - The requested Item
|
||||
*/
|
||||
public static Item getItem(String name) {
|
||||
public static Item getItem(String name)
|
||||
{
|
||||
return GameRegistry.findItem(Constants.Mod.MODID, name);
|
||||
}
|
||||
|
||||
@Getter @Setter
|
||||
@Getter
|
||||
@Setter
|
||||
private static Fluid lifeEssence;
|
||||
}
|
||||
|
|
|
@ -4,9 +4,11 @@ import net.minecraft.potion.Potion;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
public class Constants {
|
||||
public class Constants
|
||||
{
|
||||
|
||||
public static class NBT {
|
||||
public static class NBT
|
||||
{
|
||||
|
||||
public static final String OWNER_UUID = "ownerUUID";
|
||||
public static final String USES = "uses";
|
||||
|
@ -62,7 +64,8 @@ public class Constants {
|
|||
public static final String CONTAINED_BLOCK_META = "containedBlockMeta";
|
||||
}
|
||||
|
||||
public static class Mod {
|
||||
public static class Mod
|
||||
{
|
||||
|
||||
public static final String MODID = "BloodMagic";
|
||||
public static final String DOMAIN = MODID.toLowerCase(Locale.ENGLISH) + ":";
|
||||
|
@ -71,13 +74,15 @@ public class Constants {
|
|||
public static final String DEPEND = "";
|
||||
}
|
||||
|
||||
public static class Compat {
|
||||
public static class Compat
|
||||
{
|
||||
public static final String JEI_CATEGORY_ALTAR = Mod.MODID + ":altar";
|
||||
public static final String JEI_CATEGORY_BINDING = Mod.MODID + ":binding";
|
||||
public static final String JEI_CATEGORY_ALCHEMYARRAY = Mod.MODID + ":alchemyArray";
|
||||
}
|
||||
|
||||
public static class Misc {
|
||||
public static class Misc
|
||||
{
|
||||
public static final int POTION_ARRAY_SIZE = Potion.potionTypes.length;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,11 @@ import net.minecraft.util.ChatComponentText;
|
|||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
|
||||
public class DamageSourceBloodMagic extends DamageSource {
|
||||
public class DamageSourceBloodMagic extends DamageSource
|
||||
{
|
||||
|
||||
public DamageSourceBloodMagic() {
|
||||
public DamageSourceBloodMagic()
|
||||
{
|
||||
super("bloodMagic");
|
||||
|
||||
setDamageBypassesArmor();
|
||||
|
@ -16,7 +18,8 @@ public class DamageSourceBloodMagic extends DamageSource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IChatComponent getDeathMessage(EntityLivingBase livingBase) {
|
||||
public IChatComponent getDeathMessage(EntityLivingBase livingBase)
|
||||
{
|
||||
return new ChatComponentText(TextHelper.localizeEffect("chat.BloodMagic.damageSource", livingBase.getName()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
|
||||
@RequiredArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class ItemStackWrapper {
|
||||
public class ItemStackWrapper
|
||||
{
|
||||
|
||||
public final Item item;
|
||||
public final int stackSize;
|
||||
|
@ -18,44 +19,54 @@ public class ItemStackWrapper {
|
|||
@Setter
|
||||
public NBTTagCompound nbtTag;
|
||||
|
||||
public ItemStackWrapper(Item item, int stackSize) {
|
||||
public ItemStackWrapper(Item item, int stackSize)
|
||||
{
|
||||
this(item, stackSize, 0);
|
||||
}
|
||||
|
||||
public ItemStackWrapper(Item item) {
|
||||
public ItemStackWrapper(Item item)
|
||||
{
|
||||
this(item, 1, 0);
|
||||
}
|
||||
|
||||
public ItemStackWrapper(Block block, int stackSize, int meta) {
|
||||
public ItemStackWrapper(Block block, int stackSize, int meta)
|
||||
{
|
||||
this(Item.getItemFromBlock(block), stackSize, meta);
|
||||
}
|
||||
|
||||
public ItemStackWrapper(Block block, int stackSize) {
|
||||
public ItemStackWrapper(Block block, int stackSize)
|
||||
{
|
||||
this(block, stackSize, 0);
|
||||
}
|
||||
|
||||
public ItemStackWrapper(Block block) {
|
||||
public ItemStackWrapper(Block block)
|
||||
{
|
||||
this(block, 1, 0);
|
||||
}
|
||||
|
||||
public static ItemStackWrapper getHolder(ItemStack stack) {
|
||||
public static ItemStackWrapper getHolder(ItemStack stack)
|
||||
{
|
||||
return new ItemStackWrapper(stack.getItem(), stack.stackSize, stack.getItemDamage());
|
||||
}
|
||||
|
||||
public ItemStack toStack() {
|
||||
public ItemStack toStack()
|
||||
{
|
||||
return new ItemStack(item, stackSize, meta);
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
public String getDisplayName()
|
||||
{
|
||||
return toStack().getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public String toString()
|
||||
{
|
||||
return stackSize + "x" + item.getUnlocalizedName() + "@" + this.meta;
|
||||
}
|
||||
|
||||
public ItemStack toStack(int count) {
|
||||
public ItemStack toStack(int count)
|
||||
{
|
||||
ItemStack result = new ItemStack(item, count, meta);
|
||||
result.setTagCompound(nbtTag);
|
||||
return result;
|
||||
|
|
|
@ -2,8 +2,9 @@ package WayofTime.bloodmagic.api.alchemyCrafting;
|
|||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public abstract class AlchemyArrayEffect {
|
||||
|
||||
public abstract boolean update(TileEntity tile, int ticksActive);
|
||||
|
||||
public abstract class AlchemyArrayEffect
|
||||
{
|
||||
|
||||
public abstract boolean update(TileEntity tile, int ticksActive);
|
||||
|
||||
}
|
||||
|
|
|
@ -6,39 +6,45 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect {
|
||||
public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect
|
||||
{
|
||||
|
||||
@Getter
|
||||
public final ItemStack outputStack;
|
||||
public int tickLimit;
|
||||
@Getter
|
||||
public final ItemStack outputStack;
|
||||
public int tickLimit;
|
||||
|
||||
public AlchemyArrayEffectCrafting(ItemStack outputStack) {
|
||||
this(outputStack, 200);
|
||||
}
|
||||
|
||||
public AlchemyArrayEffectCrafting(ItemStack outputStack, int tickLimit) {
|
||||
this.outputStack = outputStack;
|
||||
this.tickLimit = tickLimit;
|
||||
}
|
||||
public AlchemyArrayEffectCrafting(ItemStack outputStack)
|
||||
{
|
||||
this(outputStack, 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
//TODO: Add recipe rechecking to verify nothing screwy is going on.
|
||||
if(tile.getWorld().isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(ticksActive >= tickLimit){
|
||||
BlockPos pos = tile.getPos();
|
||||
public AlchemyArrayEffectCrafting(ItemStack outputStack, int tickLimit)
|
||||
{
|
||||
this.outputStack = outputStack;
|
||||
this.tickLimit = tickLimit;
|
||||
}
|
||||
|
||||
ItemStack output = outputStack.copy();
|
||||
EntityItem outputEntity = new EntityItem(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output);
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive)
|
||||
{
|
||||
// TODO: Add recipe rechecking to verify nothing screwy is going on.
|
||||
if (tile.getWorld().isRemote)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
tile.getWorld().spawnEntityInWorld(outputEntity);
|
||||
if (ticksActive >= tickLimit)
|
||||
{
|
||||
BlockPos pos = tile.getPos();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
ItemStack output = outputStack.copy();
|
||||
EntityItem outputEntity = new EntityItem(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output);
|
||||
|
||||
tile.getWorld().spawnEntityInWorld(outputEntity);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,132 +9,146 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class AlchemyCircleRenderer {
|
||||
public class AlchemyCircleRenderer
|
||||
{
|
||||
|
||||
public float offsetFromFace = -0.9f;
|
||||
public final ResourceLocation arrayResource;
|
||||
public float offsetFromFace = -0.9f;
|
||||
public final ResourceLocation arrayResource;
|
||||
|
||||
public AlchemyCircleRenderer() {
|
||||
this(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png"));
|
||||
}
|
||||
|
||||
public AlchemyCircleRenderer(ResourceLocation arrayResource) {
|
||||
this.arrayResource = arrayResource;
|
||||
}
|
||||
public AlchemyCircleRenderer()
|
||||
{
|
||||
this(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png"));
|
||||
}
|
||||
|
||||
public float getRotation(float craftTime) {
|
||||
float offset = 2;
|
||||
if (craftTime >= offset) {
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.5);
|
||||
return modifier * 1f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public AlchemyCircleRenderer(ResourceLocation arrayResource)
|
||||
{
|
||||
this.arrayResource = arrayResource;
|
||||
}
|
||||
|
||||
public float getSecondaryRotation(float craftTime) {
|
||||
float offset = 50;
|
||||
if (craftTime >= offset) {
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.7);
|
||||
return modifier * 0.5f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public float getRotation(float craftTime)
|
||||
{
|
||||
float offset = 2;
|
||||
if (craftTime >= offset)
|
||||
{
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.5);
|
||||
return modifier * 1f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getSizeModifier(float craftTime) {
|
||||
if (craftTime >= 150 && craftTime <= 250) {
|
||||
return (200 - craftTime) / 50f;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
public float getSecondaryRotation(float craftTime)
|
||||
{
|
||||
float offset = 50;
|
||||
if (craftTime >= offset)
|
||||
{
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.7);
|
||||
return modifier * 0.5f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getVerticalOffset(float craftTime) {
|
||||
if (craftTime >= 5) {
|
||||
if (craftTime <= 40) {
|
||||
return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3));
|
||||
} else {
|
||||
return -0.4f;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public float getSizeModifier(float craftTime)
|
||||
{
|
||||
if (craftTime >= 150 && craftTime <= 250)
|
||||
{
|
||||
return (200 - craftTime) / 50f;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) {
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer wr = tessellator.getWorldRenderer();
|
||||
public float getVerticalOffset(float craftTime)
|
||||
{
|
||||
if (craftTime >= 5)
|
||||
{
|
||||
if (craftTime <= 40)
|
||||
{
|
||||
return (float) ((-0.4) * Math.pow((craftTime - 5) / 35f, 3));
|
||||
} else
|
||||
{
|
||||
return -0.4f;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
// float rot = (float)(this.worldObj.provider.getWorldTime() % (360 /
|
||||
// this.rotationspeed) * this.rotationspeed) + this.rotationspeed * f;
|
||||
float rot = getRotation(craftTime);
|
||||
float secondaryRot = getSecondaryRotation(craftTime);
|
||||
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer wr = tessellator.getWorldRenderer();
|
||||
|
||||
float size = 1.0F * getSizeModifier(craftTime);
|
||||
GlStateManager.pushMatrix();
|
||||
// float rot = (float)(this.worldObj.provider.getWorldTime() % (360 /
|
||||
// this.rotationspeed) * this.rotationspeed) + this.rotationspeed * f;
|
||||
float rot = getRotation(craftTime);
|
||||
float secondaryRot = getSecondaryRotation(craftTime);
|
||||
|
||||
// Bind the texture to the circle
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(arrayResource);
|
||||
float size = 1.0F * getSizeModifier(craftTime);
|
||||
|
||||
GlStateManager.disableCull();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(770, 1);
|
||||
// Bind the texture to the circle
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(arrayResource);
|
||||
|
||||
GlStateManager.translate(x, y, z);
|
||||
GlStateManager.disableCull();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(770, 1);
|
||||
|
||||
EnumFacing sideHit = EnumFacing.UP; // Specify which face this "circle"
|
||||
// is located on
|
||||
GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY()
|
||||
* offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace);
|
||||
GlStateManager.translate(x, y, z);
|
||||
|
||||
switch (sideHit) {
|
||||
case DOWN:
|
||||
GlStateManager.translate(0, 0, 1);
|
||||
GlStateManager.rotate(-90.0f, 1, 0, 0);
|
||||
break;
|
||||
case EAST:
|
||||
GlStateManager.rotate(-90.0f, 0, 1, 0);
|
||||
GlStateManager.translate(0, 0, -1);
|
||||
break;
|
||||
case NORTH:
|
||||
break;
|
||||
case SOUTH:
|
||||
GlStateManager.rotate(180.0f, 0, 1, 0);
|
||||
GlStateManager.translate(-1, 0, -1);
|
||||
break;
|
||||
case UP:
|
||||
GlStateManager.translate(0, 1, 0);
|
||||
GlStateManager.rotate(90.0f, 1, 0, 0);
|
||||
break;
|
||||
case WEST:
|
||||
GlStateManager.translate(0, 0, 1);
|
||||
GlStateManager.rotate(90.0f, 0, 1, 0);
|
||||
break;
|
||||
}
|
||||
EnumFacing sideHit = EnumFacing.UP; // Specify which face this "circle"
|
||||
// is located on
|
||||
GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(0.5f, 0.5f, getVerticalOffset(craftTime));
|
||||
GlStateManager.rotate(rot, 0, 0, 1);
|
||||
GlStateManager.rotate(secondaryRot, 1, 0, 0);
|
||||
GlStateManager.rotate(secondaryRot * 0.45812f, 0, 0, 1);
|
||||
double var31 = 0.0D;
|
||||
double var33 = 1.0D;
|
||||
double var35 = 0;
|
||||
double var37 = 1;
|
||||
switch (sideHit)
|
||||
{
|
||||
case DOWN:
|
||||
GlStateManager.translate(0, 0, 1);
|
||||
GlStateManager.rotate(-90.0f, 1, 0, 0);
|
||||
break;
|
||||
case EAST:
|
||||
GlStateManager.rotate(-90.0f, 0, 1, 0);
|
||||
GlStateManager.translate(0, 0, -1);
|
||||
break;
|
||||
case NORTH:
|
||||
break;
|
||||
case SOUTH:
|
||||
GlStateManager.rotate(180.0f, 0, 1, 0);
|
||||
GlStateManager.translate(-1, 0, -1);
|
||||
break;
|
||||
case UP:
|
||||
GlStateManager.translate(0, 1, 0);
|
||||
GlStateManager.rotate(90.0f, 1, 0, 0);
|
||||
break;
|
||||
case WEST:
|
||||
GlStateManager.translate(0, 0, 1);
|
||||
GlStateManager.rotate(90.0f, 0, 1, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
GlStateManager.color(0.5f, 1f, 1f, 1f);
|
||||
wr.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
// wr.setBrightness(200);
|
||||
wr.pos(size / 2f, size / 2f, 0.0D).tex(var33, var37).endVertex();
|
||||
wr.pos(size / 2f, -size / 2f, 0.0D).tex(var33, var35).endVertex();
|
||||
wr.pos(-size / 2f, -size / 2f, 0.0D).tex(var31, var35).endVertex();
|
||||
wr.pos(-size / 2f, size / 2f, 0.0D).tex(var31, var37).endVertex();
|
||||
tessellator.draw();
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(0.5f, 0.5f, getVerticalOffset(craftTime));
|
||||
GlStateManager.rotate(rot, 0, 0, 1);
|
||||
GlStateManager.rotate(secondaryRot, 1, 0, 0);
|
||||
GlStateManager.rotate(secondaryRot * 0.45812f, 0, 0, 1);
|
||||
double var31 = 0.0D;
|
||||
double var33 = 1.0D;
|
||||
double var35 = 0;
|
||||
double var37 = 1;
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.color(0.5f, 1f, 1f, 1f);
|
||||
wr.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
// wr.setBrightness(200);
|
||||
wr.pos(size / 2f, size / 2f, 0.0D).tex(var33, var37).endVertex();
|
||||
wr.pos(size / 2f, -size / 2f, 0.0D).tex(var33, var35).endVertex();
|
||||
wr.pos(-size / 2f, -size / 2f, 0.0D).tex(var31, var35).endVertex();
|
||||
wr.pos(-size / 2f, size / 2f, 0.0D).tex(var31, var37).endVertex();
|
||||
tessellator.draw();
|
||||
|
||||
// GlStateManager.depthMask(true);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableCull();
|
||||
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
// GlStateManager.depthMask(true);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableCull();
|
||||
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
|
@ -7,7 +7,8 @@ import net.minecraft.util.BlockPos;
|
|||
* Used for building the altar structure.
|
||||
*/
|
||||
@Getter
|
||||
public class AltarComponent {
|
||||
public class AltarComponent
|
||||
{
|
||||
|
||||
private BlockPos offset;
|
||||
private boolean upgradeSlot;
|
||||
|
@ -16,11 +17,14 @@ public class AltarComponent {
|
|||
|
||||
/**
|
||||
* Sets a component location for the altar.
|
||||
*
|
||||
* @param offset - Where the block should be in relation to the Altar
|
||||
* @param component - The type of Component the location should contain
|
||||
*
|
||||
* @param offset
|
||||
* - Where the block should be in relation to the Altar
|
||||
* @param component
|
||||
* - The type of Component the location should contain
|
||||
*/
|
||||
public AltarComponent(BlockPos offset, EnumAltarComponent component) {
|
||||
public AltarComponent(BlockPos offset, EnumAltarComponent component)
|
||||
{
|
||||
this.offset = offset;
|
||||
this.component = component;
|
||||
}
|
||||
|
@ -29,16 +33,18 @@ public class AltarComponent {
|
|||
* Use for setting a location at which there must be a block, but the type
|
||||
* of block does not matter.
|
||||
*/
|
||||
public AltarComponent(BlockPos offset) {
|
||||
public AltarComponent(BlockPos offset)
|
||||
{
|
||||
this(offset, EnumAltarComponent.NOTAIR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location to an upgrade slot.
|
||||
*
|
||||
*
|
||||
* @return the current instance for further use.
|
||||
*/
|
||||
public AltarComponent setUpgradeSlot() {
|
||||
public AltarComponent setUpgradeSlot()
|
||||
{
|
||||
this.upgradeSlot = true;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@ import lombok.NoArgsConstructor;
|
|||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AltarUpgrade {
|
||||
public class AltarUpgrade
|
||||
{
|
||||
|
||||
private int speedCount;
|
||||
private int efficiencyCount;
|
||||
|
@ -21,47 +22,56 @@ public class AltarUpgrade {
|
|||
|
||||
// Adders
|
||||
|
||||
public AltarUpgrade addSpeed() {
|
||||
public AltarUpgrade addSpeed()
|
||||
{
|
||||
speedCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addEfficiency() {
|
||||
public AltarUpgrade addEfficiency()
|
||||
{
|
||||
efficiencyCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addSacrifice() {
|
||||
public AltarUpgrade addSacrifice()
|
||||
{
|
||||
sacrificeCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addSelfSacrifice() {
|
||||
public AltarUpgrade addSelfSacrifice()
|
||||
{
|
||||
selfSacrificeCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addDisplacement() {
|
||||
public AltarUpgrade addDisplacement()
|
||||
{
|
||||
displacementCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addCapacity() {
|
||||
public AltarUpgrade addCapacity()
|
||||
{
|
||||
capacityCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addOrbCapacity() {
|
||||
public AltarUpgrade addOrbCapacity()
|
||||
{
|
||||
orbCapacityCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addBetterCapacity() {
|
||||
public AltarUpgrade addBetterCapacity()
|
||||
{
|
||||
betterCapacityCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AltarUpgrade addAcceleration() {
|
||||
public AltarUpgrade addAcceleration()
|
||||
{
|
||||
accelerationCount++;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
package WayofTime.bloodmagic.api.altar;
|
||||
|
||||
public enum EnumAltarComponent {
|
||||
public enum EnumAltarComponent
|
||||
{
|
||||
|
||||
GLOWSTONE,
|
||||
BLOODSTONE,
|
||||
BEACON,
|
||||
BLOODRUNE,
|
||||
CRYSTAL,
|
||||
NOTAIR
|
||||
GLOWSTONE, BLOODSTONE, BEACON, BLOODRUNE, CRYSTAL, NOTAIR
|
||||
}
|
||||
|
|
|
@ -6,11 +6,13 @@ import net.minecraft.util.BlockPos;
|
|||
import java.util.ArrayList;
|
||||
|
||||
@Getter
|
||||
public enum EnumAltarTier {
|
||||
ONE(),
|
||||
TWO() {
|
||||
public enum EnumAltarTier
|
||||
{
|
||||
ONE(), TWO()
|
||||
{
|
||||
@Override
|
||||
public void buildComponents() {
|
||||
public void buildComponents()
|
||||
{
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, -1), EnumAltarComponent.BLOODRUNE));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(0, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(1, -1, -1), EnumAltarComponent.BLOODRUNE));
|
||||
|
@ -21,9 +23,11 @@ public enum EnumAltarTier {
|
|||
altarComponents.add(new AltarComponent(new BlockPos(1, -1, 1), EnumAltarComponent.BLOODRUNE));
|
||||
}
|
||||
},
|
||||
THREE() {
|
||||
THREE()
|
||||
{
|
||||
@Override
|
||||
public void buildComponents() {
|
||||
public void buildComponents()
|
||||
{
|
||||
altarComponents.addAll(TWO.getAltarComponents());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-1, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(0, -1, -1), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
|
@ -46,7 +50,8 @@ public enum EnumAltarTier {
|
|||
altarComponents.add(new AltarComponent(new BlockPos(-3, 1, 3), EnumAltarComponent.GLOWSTONE));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(3, 1, 3), EnumAltarComponent.GLOWSTONE));
|
||||
|
||||
for (int i = -2; i <= 2; i++) {
|
||||
for (int i = -2; i <= 2; i++)
|
||||
{
|
||||
altarComponents.add(new AltarComponent(new BlockPos(3, -2, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-3, -2, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(i, -2, 3), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
|
@ -54,19 +59,23 @@ public enum EnumAltarTier {
|
|||
}
|
||||
}
|
||||
},
|
||||
FOUR() {
|
||||
FOUR()
|
||||
{
|
||||
@Override
|
||||
public void buildComponents() {
|
||||
public void buildComponents()
|
||||
{
|
||||
altarComponents.addAll(THREE.getAltarComponents());
|
||||
|
||||
for (int i = -3; i <= 3; i++) {
|
||||
for (int i = -3; i <= 3; i++)
|
||||
{
|
||||
altarComponents.add(new AltarComponent(new BlockPos(5, -3, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-5, -3, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(i, -3, 5), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(i, -3, -5), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
}
|
||||
|
||||
for (int i = -2; i <= 1; i++) {
|
||||
for (int i = -2; i <= 1; i++)
|
||||
{
|
||||
altarComponents.add(new AltarComponent(new BlockPos(5, i, 5)));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(5, i, -5)));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-5, i, -5)));
|
||||
|
@ -79,16 +88,19 @@ public enum EnumAltarTier {
|
|||
altarComponents.add(new AltarComponent(new BlockPos(-5, 2, 5), EnumAltarComponent.BLOODSTONE));
|
||||
}
|
||||
},
|
||||
FIVE() {
|
||||
FIVE()
|
||||
{
|
||||
@Override
|
||||
public void buildComponents() {
|
||||
public void buildComponents()
|
||||
{
|
||||
altarComponents.addAll(FOUR.getAltarComponents());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-8, -3, 8), EnumAltarComponent.BEACON));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-8, -3, -8), EnumAltarComponent.BEACON));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(8, -3, -8), EnumAltarComponent.BEACON));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(8, -3, 8), EnumAltarComponent.BEACON));
|
||||
|
||||
for (int i = -6; i <= 6; i++) {
|
||||
for (int i = -6; i <= 6; i++)
|
||||
{
|
||||
altarComponents.add(new AltarComponent(new BlockPos(8, -4, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-8, -4, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(i, -4, 8), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
|
@ -96,12 +108,15 @@ public enum EnumAltarTier {
|
|||
}
|
||||
}
|
||||
},
|
||||
SIX() {
|
||||
SIX()
|
||||
{
|
||||
@Override
|
||||
public void buildComponents() {
|
||||
public void buildComponents()
|
||||
{
|
||||
altarComponents.addAll(FIVE.getAltarComponents());
|
||||
|
||||
for (int i = -4; i <= 2; i++) {
|
||||
for (int i = -4; i <= 2; i++)
|
||||
{
|
||||
altarComponents.add(new AltarComponent(new BlockPos(11, i, 11)));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-11, i, -11)));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(11, i, -11)));
|
||||
|
@ -113,7 +128,8 @@ public enum EnumAltarTier {
|
|||
altarComponents.add(new AltarComponent(new BlockPos(11, 3, -11), EnumAltarComponent.CRYSTAL));
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-11, 3, 11), EnumAltarComponent.CRYSTAL));
|
||||
|
||||
for (int i = -9; i <= 9; i++) {
|
||||
for (int i = -9; i <= 9; i++)
|
||||
{
|
||||
altarComponents.add(new AltarComponent(new BlockPos(11, -5, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(-11, -5, i), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
altarComponents.add(new AltarComponent(new BlockPos(i, -5, 11), EnumAltarComponent.BLOODRUNE).setUpgradeSlot());
|
||||
|
@ -126,11 +142,13 @@ public enum EnumAltarTier {
|
|||
|
||||
ArrayList<AltarComponent> altarComponents = new ArrayList<AltarComponent>();
|
||||
|
||||
public void buildComponents() {
|
||||
public void buildComponents()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public int toInt() {
|
||||
public int toInt()
|
||||
{
|
||||
return ordinal() + 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package WayofTime.bloodmagic.api.altar;
|
||||
|
||||
public interface IAltarComponent {
|
||||
public interface IAltarComponent
|
||||
{
|
||||
|
||||
EnumAltarComponent getType(int meta);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package WayofTime.bloodmagic.api.altar;
|
||||
|
||||
/**
|
||||
* Any item that implements this interface will not be pulled into the Altar
|
||||
* on right click.
|
||||
* Any item that implements this interface will not be pulled into the Altar on
|
||||
* right click.
|
||||
*/
|
||||
public interface IAltarManipulator {
|
||||
public interface IAltarManipulator
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package WayofTime.bloodmagic.api.altar;
|
||||
|
||||
public interface IBloodAltar {
|
||||
public interface IBloodAltar
|
||||
{
|
||||
|
||||
int getCapacity();
|
||||
|
||||
|
@ -31,18 +32,20 @@ public interface IBloodAltar {
|
|||
void startCycle();
|
||||
|
||||
void checkTier();
|
||||
|
||||
|
||||
boolean isActive();
|
||||
|
||||
|
||||
void setActive();
|
||||
|
||||
|
||||
int fillMainTank(int amount);
|
||||
|
||||
/**
|
||||
* Will set the altar to initiate a cooldown cycle after it crafts before starting to craft again, giving the user time to interact with the altar.
|
||||
* Will set the altar to initiate a cooldown cycle after it crafts before
|
||||
* starting to craft again, giving the user time to interact with the altar.
|
||||
* This can only be set while the altar is not active.
|
||||
*
|
||||
* @param cooldown - How long the cooldown should last
|
||||
*
|
||||
* @param cooldown
|
||||
* - How long the cooldown should last
|
||||
*/
|
||||
void requestPauseAfterCrafting(int cooldown);
|
||||
}
|
||||
|
|
|
@ -3,12 +3,16 @@ package WayofTime.bloodmagic.api.compress;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class CompressionHandler {
|
||||
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
|
||||
* 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);
|
||||
}
|
||||
|
|
|
@ -9,31 +9,40 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A registry aimed to help compress items in an inventory into its compressible form.
|
||||
* A registry aimed to help compress items in an inventory into its compressible
|
||||
* form.
|
||||
*/
|
||||
public class CompressionRegistry {
|
||||
public class CompressionRegistry
|
||||
{
|
||||
|
||||
public static List<CompressionHandler> compressionRegistry = new ArrayList<CompressionHandler>();
|
||||
public static Map<ItemStack, Integer> thresholdMap = new HashMap<ItemStack, Integer>();
|
||||
|
||||
public static void registerHandler(CompressionHandler handler) {
|
||||
public static void registerHandler(CompressionHandler handler)
|
||||
{
|
||||
compressionRegistry.add(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an item so that it only compresses while above this threshold
|
||||
*
|
||||
* @param stack item/block to be compressed
|
||||
* @param threshold amount that is to be compressed
|
||||
*
|
||||
* @param stack
|
||||
* item/block to be compressed
|
||||
* @param threshold
|
||||
* amount that is to be compressed
|
||||
*/
|
||||
public static void registerItemThreshold(ItemStack stack, int threshold) {
|
||||
public static void registerItemThreshold(ItemStack stack, int threshold)
|
||||
{
|
||||
thresholdMap.put(stack, threshold);
|
||||
}
|
||||
|
||||
public static ItemStack compressInventory(ItemStack[] inv, World world) {
|
||||
for (CompressionHandler handler : compressionRegistry) {
|
||||
public static ItemStack compressInventory(ItemStack[] inv, World world)
|
||||
{
|
||||
for (CompressionHandler handler : compressionRegistry)
|
||||
{
|
||||
ItemStack stack = handler.compressInventory(inv, world);
|
||||
if (stack != null) {
|
||||
if (stack != null)
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
@ -41,9 +50,12 @@ public class CompressionRegistry {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static int getItemThreshold(ItemStack stack) {
|
||||
for (Map.Entry<ItemStack, Integer> entry : thresholdMap.entrySet()) {
|
||||
if (areItemStacksEqual(entry.getKey(), stack)) {
|
||||
public static int getItemThreshold(ItemStack stack)
|
||||
{
|
||||
for (Map.Entry<ItemStack, Integer> entry : thresholdMap.entrySet())
|
||||
{
|
||||
if (areItemStacksEqual(entry.getKey(), stack))
|
||||
{
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +63,8 @@ public class CompressionRegistry {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public static boolean areItemStacksEqual(ItemStack stack, ItemStack compressedStack) {
|
||||
public static boolean areItemStacksEqual(ItemStack stack, ItemStack compressedStack)
|
||||
{
|
||||
return stack.isItemEqual(compressedStack) && (stack.getTagCompound() == null ? compressedStack.getTagCompound() == null : stack.getTagCompound().equals(compressedStack.getTagCompound()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,21 +2,27 @@ package WayofTime.bloodmagic.api.event;
|
|||
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
public class AddToNetworkEvent extends Event {
|
||||
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
|
||||
* 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) {
|
||||
public AddToNetworkEvent(String ownerNetwork, int addedAmount, int maximum)
|
||||
{
|
||||
this.ownerNetwork = ownerNetwork;
|
||||
this.addedAmount = addedAmount;
|
||||
this.maximum = maximum;
|
||||
|
|
|
@ -5,32 +5,38 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
public class BoundToolEvent extends Event {
|
||||
public class BoundToolEvent extends Event
|
||||
{
|
||||
|
||||
public EntityPlayer player;
|
||||
|
||||
public BoundToolEvent(EntityPlayer player) {
|
||||
public BoundToolEvent(EntityPlayer player)
|
||||
{
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class Charge extends BoundToolEvent {
|
||||
public static class Charge extends BoundToolEvent
|
||||
{
|
||||
|
||||
public ItemStack result;
|
||||
|
||||
public Charge(EntityPlayer player, ItemStack result) {
|
||||
public Charge(EntityPlayer player, ItemStack result)
|
||||
{
|
||||
super(player);
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class Release extends BoundToolEvent {
|
||||
public static class Release extends BoundToolEvent
|
||||
{
|
||||
|
||||
public final ItemStack boundTool;
|
||||
public int charge;
|
||||
|
||||
public Release(EntityPlayer player, ItemStack boundTool, int charge) {
|
||||
public Release(EntityPlayer player, ItemStack boundTool, int charge)
|
||||
{
|
||||
super(player);
|
||||
this.boundTool = boundTool;
|
||||
this.charge = charge;
|
||||
|
|
|
@ -6,13 +6,15 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
|||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
@Cancelable
|
||||
public class ItemBindEvent extends Event {
|
||||
public class ItemBindEvent extends Event
|
||||
{
|
||||
|
||||
public final EntityPlayer player;
|
||||
public String key;
|
||||
public ItemStack itemStack;
|
||||
|
||||
public ItemBindEvent(EntityPlayer player, String key, ItemStack itemStack) {
|
||||
public ItemBindEvent(EntityPlayer player, String key, ItemStack itemStack)
|
||||
{
|
||||
super();
|
||||
this.player = player;
|
||||
this.key = key;
|
||||
|
|
|
@ -12,30 +12,35 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
public class RitualEvent extends Event {
|
||||
public class RitualEvent extends Event
|
||||
{
|
||||
|
||||
public final IMasterRitualStone mrs;
|
||||
public final String ownerName;
|
||||
public final Ritual ritual;
|
||||
|
||||
private RitualEvent(IMasterRitualStone mrs, String ownerName, Ritual ritual) {
|
||||
private RitualEvent(IMasterRitualStone mrs, String ownerName, Ritual ritual)
|
||||
{
|
||||
this.mrs = mrs;
|
||||
this.ownerName = ownerName;
|
||||
this.ritual = ritual;
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is called when a ritual is activated. If cancelled, it will not activate.
|
||||
*
|
||||
* This event is called when a ritual is activated. If cancelled, it will
|
||||
* not activate.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#activateRitual(ItemStack, EntityPlayer, Ritual)}
|
||||
*/
|
||||
@Cancelable
|
||||
public static class RitualActivatedEvent extends RitualEvent {
|
||||
public static class RitualActivatedEvent extends RitualEvent
|
||||
{
|
||||
public final EntityPlayer player;
|
||||
public final ItemStack crystalStack;
|
||||
public int crystalTier;
|
||||
|
||||
public RitualActivatedEvent(IMasterRitualStone mrs, String owner, Ritual ritual, EntityPlayer player, ItemStack activationCrystal, int crystalTier) {
|
||||
public RitualActivatedEvent(IMasterRitualStone mrs, String owner, Ritual ritual, EntityPlayer player, ItemStack activationCrystal, int crystalTier)
|
||||
{
|
||||
super(mrs, owner, ritual);
|
||||
|
||||
this.player = player;
|
||||
|
@ -45,28 +50,34 @@ public class RitualEvent extends Event {
|
|||
}
|
||||
|
||||
/**
|
||||
* This event is called when a Ritual effect is performed. If cancelled, the effect will not happen.
|
||||
*
|
||||
* This event is called when a Ritual effect is performed. If cancelled, the
|
||||
* effect will not happen.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, BlockPos)}
|
||||
*/
|
||||
@Cancelable
|
||||
public static class RitualRunEvent extends RitualEvent {
|
||||
public static class RitualRunEvent extends RitualEvent
|
||||
{
|
||||
|
||||
public RitualRunEvent(IMasterRitualStone mrs, String owner, Ritual ritual) {
|
||||
public RitualRunEvent(IMasterRitualStone mrs, String owner, Ritual ritual)
|
||||
{
|
||||
super(mrs, owner, ritual);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is called when a Ritual is stopped by a {@link Ritual.BreakType}.
|
||||
*
|
||||
* This event is called when a Ritual is stopped by a
|
||||
* {@link Ritual.BreakType}.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(Ritual.BreakType)}
|
||||
* */
|
||||
public static class RitualStopEvent extends RitualEvent {
|
||||
public static class RitualStopEvent extends RitualEvent
|
||||
{
|
||||
|
||||
public final Ritual.BreakType method;
|
||||
|
||||
public RitualStopEvent(IMasterRitualStone mrs, String owner, Ritual ritual, Ritual.BreakType method) {
|
||||
public RitualStopEvent(IMasterRitualStone mrs, String owner, Ritual ritual, Ritual.BreakType method)
|
||||
{
|
||||
super(mrs, owner, ritual);
|
||||
|
||||
this.method = method;
|
||||
|
@ -74,13 +85,15 @@ public class RitualEvent extends Event {
|
|||
}
|
||||
|
||||
@Cancelable
|
||||
public static class ImperfectRitualActivatedEvent extends Event {
|
||||
public static class ImperfectRitualActivatedEvent extends Event
|
||||
{
|
||||
|
||||
public final IImperfectRitualStone ims;
|
||||
public final String ownerName;
|
||||
public final ImperfectRitual imperfectRitual;
|
||||
|
||||
public ImperfectRitualActivatedEvent(IImperfectRitualStone ims, String ownerName, ImperfectRitual imperfectRitual) {
|
||||
public ImperfectRitualActivatedEvent(IImperfectRitualStone ims, String ownerName, ImperfectRitual imperfectRitual)
|
||||
{
|
||||
this.ims = ims;
|
||||
this.ownerName = ownerName;
|
||||
this.imperfectRitual = imperfectRitual;
|
||||
|
|
|
@ -5,13 +5,15 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
|||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
@Cancelable
|
||||
public class SacrificeKnifeUsedEvent extends Event {
|
||||
public class SacrificeKnifeUsedEvent extends Event
|
||||
{
|
||||
public final EntityPlayer player;
|
||||
public final int healthDrained;
|
||||
public boolean shouldDrainHealth;
|
||||
public boolean shouldFillAltar;
|
||||
|
||||
public SacrificeKnifeUsedEvent(EntityPlayer player, boolean shouldDrainHealth, boolean shouldFillAltar, int hp) {
|
||||
public SacrificeKnifeUsedEvent(EntityPlayer player, boolean shouldDrainHealth, boolean shouldFillAltar, int hp)
|
||||
{
|
||||
this.player = player;
|
||||
this.shouldDrainHealth = shouldDrainHealth;
|
||||
this.shouldFillAltar = shouldFillAltar;
|
||||
|
|
|
@ -5,34 +5,41 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
public class SoulNetworkEvent extends Event {
|
||||
public class SoulNetworkEvent extends Event
|
||||
{
|
||||
|
||||
public final String ownerName;
|
||||
public int syphon;
|
||||
|
||||
public SoulNetworkEvent(String ownerName, int syphon) {
|
||||
public SoulNetworkEvent(String ownerName, int syphon)
|
||||
{
|
||||
this.ownerName = ownerName;
|
||||
this.syphon = syphon;
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class ItemDrainInContainerEvent extends SoulNetworkEvent {
|
||||
public static class ItemDrainInContainerEvent extends SoulNetworkEvent
|
||||
{
|
||||
|
||||
public ItemStack stack;
|
||||
|
||||
public ItemDrainInContainerEvent(ItemStack stack, String ownerName, int syphon) {
|
||||
public ItemDrainInContainerEvent(ItemStack stack, String ownerName, int syphon)
|
||||
{
|
||||
super(ownerName, syphon);
|
||||
this.stack = stack;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class PlayerDrainNetworkEvent extends SoulNetworkEvent {
|
||||
public static class PlayerDrainNetworkEvent extends SoulNetworkEvent
|
||||
{
|
||||
|
||||
public final EntityPlayer player;
|
||||
public boolean shouldDamage; //If true, will damage regardless of if the network had enough inside it
|
||||
public boolean shouldDamage; // If true, will damage regardless of if
|
||||
// the network had enough inside it
|
||||
|
||||
public PlayerDrainNetworkEvent(EntityPlayer player, String ownerNetwork, int drainAmount) {
|
||||
public PlayerDrainNetworkEvent(EntityPlayer player, String ownerNetwork, int drainAmount)
|
||||
{
|
||||
super(ownerNetwork, drainAmount);
|
||||
this.shouldDamage = false;
|
||||
this.player = player;
|
||||
|
@ -40,20 +47,28 @@ public class SoulNetworkEvent extends Event {
|
|||
}
|
||||
|
||||
@Cancelable
|
||||
public static class ItemDrainNetworkEvent extends PlayerDrainNetworkEvent {
|
||||
public static class ItemDrainNetworkEvent extends PlayerDrainNetworkEvent
|
||||
{
|
||||
|
||||
public final ItemStack itemStack;
|
||||
public float damageAmount; //Amount of damage that would incur if the network could not drain properly
|
||||
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
|
||||
* 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) {
|
||||
public ItemDrainNetworkEvent(EntityPlayer player, String ownerNetwork, ItemStack itemStack, int drainAmount)
|
||||
{
|
||||
super(player, ownerNetwork, drainAmount);
|
||||
this.itemStack = itemStack;
|
||||
this.damageAmount = (float) (drainAmount) / 100.0f;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package WayofTime.bloodmagic.api.iface;
|
||||
|
||||
public interface IAltarReader {
|
||||
public interface IAltarReader
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -6,11 +6,12 @@ import net.minecraft.item.ItemStack;
|
|||
/**
|
||||
* Implement this interface on any Item that can be bound to a player.
|
||||
*/
|
||||
public interface IBindable {
|
||||
public interface IBindable
|
||||
{
|
||||
|
||||
/**
|
||||
* Called when the player attempts to bind the item.
|
||||
*
|
||||
*
|
||||
* If false, binding fails.
|
||||
*/
|
||||
boolean onBind(EntityPlayer player, ItemStack stack);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
package WayofTime.bloodmagic.api.iface;
|
||||
|
||||
public interface ISigil {
|
||||
public interface ISigil
|
||||
{
|
||||
}
|
||||
|
|
|
@ -7,55 +7,68 @@ import java.util.List;
|
|||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class LivingArmourHandler {
|
||||
public static List<Class<? extends StatTracker>> trackers = new ArrayList();
|
||||
public static HashMap<String, Class<? extends LivingArmourUpgrade>> upgradeMap = new HashMap();
|
||||
public static HashMap<String, Constructor<? extends LivingArmourUpgrade>> upgradeConstructorMap = new HashMap();
|
||||
public class LivingArmourHandler
|
||||
{
|
||||
public static List<Class<? extends StatTracker>> trackers = new ArrayList();
|
||||
public static HashMap<String, Class<? extends LivingArmourUpgrade>> upgradeMap = new HashMap();
|
||||
public static HashMap<String, Constructor<? extends LivingArmourUpgrade>> upgradeConstructorMap = new HashMap();
|
||||
|
||||
public static void registerStatTracker(Class<? extends StatTracker> tracker) {
|
||||
trackers.add(tracker);
|
||||
}
|
||||
public static void registerStatTracker(Class<? extends StatTracker> tracker)
|
||||
{
|
||||
trackers.add(tracker);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a LivingArmourUpgrade using its unique identifier and class.
|
||||
* This is done to more easily load upgrades
|
||||
*
|
||||
* @param upgrade
|
||||
*/
|
||||
public static void registerArmourUpgrade(LivingArmourUpgrade upgrade) {
|
||||
Class<? extends LivingArmourUpgrade> clazz = upgrade.getClass();
|
||||
upgradeMap.put(upgrade.getUniqueIdentifier(), clazz);
|
||||
try {
|
||||
Constructor<? extends LivingArmourUpgrade> ctor = clazz.getConstructor(int.class);
|
||||
if (ctor == null) {
|
||||
// TODO: This is bad - add something to the log
|
||||
} else {
|
||||
upgradeConstructorMap.put(upgrade.getUniqueIdentifier(), ctor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
/**
|
||||
* Registers a LivingArmourUpgrade using its unique identifier and class.
|
||||
* This is done to more easily load upgrades
|
||||
*
|
||||
* @param upgrade
|
||||
*/
|
||||
public static void registerArmourUpgrade(LivingArmourUpgrade upgrade)
|
||||
{
|
||||
Class<? extends LivingArmourUpgrade> clazz = upgrade.getClass();
|
||||
upgradeMap.put(upgrade.getUniqueIdentifier(), clazz);
|
||||
try
|
||||
{
|
||||
Constructor<? extends LivingArmourUpgrade> ctor = clazz.getConstructor(int.class);
|
||||
if (ctor == null)
|
||||
{
|
||||
// TODO: This is bad - add something to the log
|
||||
} else
|
||||
{
|
||||
upgradeConstructorMap.put(upgrade.getUniqueIdentifier(), ctor);
|
||||
}
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level) {
|
||||
return generateUpgradeFromKey(key, level, null);
|
||||
}
|
||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level)
|
||||
{
|
||||
return generateUpgradeFromKey(key, level, null);
|
||||
}
|
||||
|
||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level, NBTTagCompound tag) {
|
||||
Constructor<? extends LivingArmourUpgrade> ctor = upgradeConstructorMap.get(key);
|
||||
if (ctor != null) {
|
||||
try {
|
||||
LivingArmourUpgrade upgrade = ctor.newInstance(level);
|
||||
if (upgrade != null && tag != null) {
|
||||
upgrade.readFromNBT(tag);
|
||||
}
|
||||
return upgrade;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static LivingArmourUpgrade generateUpgradeFromKey(String key, int level, NBTTagCompound tag)
|
||||
{
|
||||
Constructor<? extends LivingArmourUpgrade> ctor = upgradeConstructorMap.get(key);
|
||||
if (ctor != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
LivingArmourUpgrade upgrade = ctor.newInstance(level);
|
||||
if (upgrade != null && tag != null)
|
||||
{
|
||||
upgrade.readFromNBT(tag);
|
||||
}
|
||||
return upgrade;
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,45 +9,50 @@ import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
|||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
public abstract class LivingArmourUpgrade {
|
||||
public abstract class LivingArmourUpgrade
|
||||
{
|
||||
|
||||
protected int level = 0; // Upgrade level 0 is the first upgrade. Upgrade
|
||||
// goes from 0 to getMaxTier() - 1.
|
||||
protected int level = 0; // Upgrade level 0 is the first upgrade. Upgrade
|
||||
// goes from 0 to getMaxTier() - 1.
|
||||
|
||||
/**
|
||||
* The LivingArmourUpgrade must have a constructor that has a single integer
|
||||
* parameter. Upgrades may have other constructors, but must have one of
|
||||
* these.
|
||||
*
|
||||
* @param level
|
||||
* The level of the upgrade
|
||||
*/
|
||||
public LivingArmourUpgrade(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int getUpgradeLevel()
|
||||
{
|
||||
return this.level;
|
||||
}
|
||||
/**
|
||||
* The LivingArmourUpgrade must have a constructor that has a single integer
|
||||
* parameter. Upgrades may have other constructors, but must have one of
|
||||
* these.
|
||||
*
|
||||
* @param level
|
||||
* The level of the upgrade
|
||||
*/
|
||||
public LivingArmourUpgrade(int level)
|
||||
{
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public abstract String getUniqueIdentifier();
|
||||
public int getUpgradeLevel()
|
||||
{
|
||||
return this.level;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract int getMaxTier();
|
||||
|
||||
public abstract int getCostOfUpgrade();
|
||||
|
||||
public void onTick(World world, EntityPlayer player, LivingArmour livingArmour){}
|
||||
public abstract String getUniqueIdentifier();
|
||||
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers() {
|
||||
return HashMultimap.<String, AttributeModifier> create();
|
||||
}
|
||||
|
||||
public abstract void writeToNBT(NBTTagCompound tag);
|
||||
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract int getMaxTier();
|
||||
|
||||
public abstract int getCostOfUpgrade();
|
||||
|
||||
public void onTick(World world, EntityPlayer player, LivingArmour livingArmour)
|
||||
{
|
||||
}
|
||||
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers()
|
||||
{
|
||||
return HashMultimap.<String, AttributeModifier> create();
|
||||
}
|
||||
|
||||
public abstract void writeToNBT(NBTTagCompound tag);
|
||||
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
}
|
||||
|
|
|
@ -5,47 +5,51 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
|
||||
public abstract class StatTracker {
|
||||
public abstract class StatTracker
|
||||
{
|
||||
|
||||
private boolean isDirty = false;
|
||||
private boolean isDirty = false;
|
||||
|
||||
public abstract String getUniqueIdentifier();
|
||||
public abstract String getUniqueIdentifier();
|
||||
|
||||
/**
|
||||
* When called the StatTracker should reset all of its data, including
|
||||
* upgrades.
|
||||
*/
|
||||
public abstract void resetTracker();
|
||||
/**
|
||||
* When called the StatTracker should reset all of its data, including
|
||||
* upgrades.
|
||||
*/
|
||||
public abstract void resetTracker();
|
||||
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
|
||||
public abstract void writeToNBT(NBTTagCompound tag);
|
||||
public abstract void writeToNBT(NBTTagCompound tag);
|
||||
|
||||
/**
|
||||
* Called each tick to update the tracker's information. Called in
|
||||
* LivingArmour
|
||||
*
|
||||
* @param world
|
||||
* World the player is in
|
||||
* @param player
|
||||
* The player that has the armour equipped
|
||||
* @param livingArmour
|
||||
* The equipped LivingArmour
|
||||
* @return True if there is a new upgrade unlocked this tick.
|
||||
*/
|
||||
public abstract boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour);
|
||||
/**
|
||||
* Called each tick to update the tracker's information. Called in
|
||||
* LivingArmour
|
||||
*
|
||||
* @param world
|
||||
* World the player is in
|
||||
* @param player
|
||||
* The player that has the armour equipped
|
||||
* @param livingArmour
|
||||
* The equipped LivingArmour
|
||||
* @return True if there is a new upgrade unlocked this tick.
|
||||
*/
|
||||
public abstract boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour);
|
||||
|
||||
public abstract LivingArmourUpgrade[] getUpgrades();
|
||||
public abstract LivingArmourUpgrade[] getUpgrades();
|
||||
|
||||
public final boolean isDirty() {
|
||||
return isDirty;
|
||||
}
|
||||
public final boolean isDirty()
|
||||
{
|
||||
return isDirty;
|
||||
}
|
||||
|
||||
public final void markDirty() {
|
||||
this.isDirty = true;
|
||||
}
|
||||
public final void markDirty()
|
||||
{
|
||||
this.isDirty = true;
|
||||
}
|
||||
|
||||
public final void resetDirty() {
|
||||
this.isDirty = false;
|
||||
}
|
||||
public final void resetDirty()
|
||||
{
|
||||
this.isDirty = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,14 +22,16 @@ import javax.annotation.Nullable;
|
|||
|
||||
@Getter
|
||||
@Setter
|
||||
public class SoulNetwork extends WorldSavedData {
|
||||
public class SoulNetwork extends WorldSavedData
|
||||
{
|
||||
|
||||
@Nullable
|
||||
private final EntityPlayer player;
|
||||
private int currentEssence;
|
||||
private int orbTier;
|
||||
|
||||
public SoulNetwork(String name) {
|
||||
public SoulNetwork(String name)
|
||||
{
|
||||
super(name);
|
||||
|
||||
currentEssence = 0;
|
||||
|
@ -38,18 +40,21 @@ public class SoulNetwork extends WorldSavedData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
currentEssence = nbttagcompound.getInteger(Constants.NBT.CURRENT_ESSENCE);
|
||||
orbTier = nbttagcompound.getInteger(Constants.NBT.ORB_TIER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
nbttagcompound.setInteger(Constants.NBT.CURRENT_ESSENCE, currentEssence);
|
||||
nbttagcompound.setInteger(Constants.NBT.ORB_TIER, orbTier);
|
||||
}
|
||||
|
||||
public int addLifeEssence(int toAdd, int maximum) {
|
||||
public int addLifeEssence(int toAdd, int maximum)
|
||||
{
|
||||
AddToNetworkEvent event = new AddToNetworkEvent(mapName, toAdd, maximum);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
|
@ -61,7 +66,8 @@ public class SoulNetwork extends WorldSavedData {
|
|||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
SoulNetwork data = (SoulNetwork) world.loadItemData(SoulNetwork.class, event.ownerNetwork);
|
||||
|
||||
if (data == null) {
|
||||
if (data == null)
|
||||
{
|
||||
data = new SoulNetwork(event.ownerNetwork);
|
||||
world.setItemData(event.ownerNetwork, data);
|
||||
}
|
||||
|
@ -83,8 +89,10 @@ public class SoulNetwork extends WorldSavedData {
|
|||
/**
|
||||
* Used to syphon LP from the network
|
||||
*/
|
||||
public int syphon(int syphon) {
|
||||
if (getCurrentEssence() >= syphon) {
|
||||
public int syphon(int syphon)
|
||||
{
|
||||
if (getCurrentEssence() >= syphon)
|
||||
{
|
||||
setCurrentEssence(getCurrentEssence() - syphon);
|
||||
markDirty();
|
||||
return syphon;
|
||||
|
@ -94,19 +102,22 @@ public class SoulNetwork extends WorldSavedData {
|
|||
}
|
||||
|
||||
/**
|
||||
* If the player exists on the server, syphon the given amount of LP from the player's LP network and
|
||||
* damage for any remaining LP required.
|
||||
*
|
||||
* If the player exists on the server, syphon the given amount of LP from
|
||||
* the player's LP network and damage for any remaining LP required.
|
||||
*
|
||||
* Always returns false on the client side.
|
||||
*
|
||||
*
|
||||
* @return - Whether the action should be performed.
|
||||
*/
|
||||
public boolean syphonAndDamage(int toSyphon) {
|
||||
if (getPlayer() != null) {
|
||||
public boolean syphonAndDamage(int toSyphon)
|
||||
{
|
||||
if (getPlayer() != null)
|
||||
{
|
||||
if (getPlayer().worldObj.isRemote)
|
||||
return false;
|
||||
|
||||
if (!Strings.isNullOrEmpty(mapName)) {
|
||||
if (!Strings.isNullOrEmpty(mapName))
|
||||
{
|
||||
SoulNetworkEvent.ItemDrainNetworkEvent event = new SoulNetworkEvent.ItemDrainNetworkEvent(player, mapName, getPlayer().getHeldItem(), toSyphon);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
|
@ -129,18 +140,25 @@ public class SoulNetwork extends WorldSavedData {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void hurtPlayer(float syphon) {
|
||||
if (getPlayer() != null) {
|
||||
public void hurtPlayer(float syphon)
|
||||
{
|
||||
if (getPlayer() != null)
|
||||
{
|
||||
getPlayer().addPotionEffect(new PotionEffect(Potion.confusion.getId(), 20));
|
||||
if (syphon < 100 && syphon > 0) {
|
||||
if (!getPlayer().capabilities.isCreativeMode) {
|
||||
if (syphon < 100 && syphon > 0)
|
||||
{
|
||||
if (!getPlayer().capabilities.isCreativeMode)
|
||||
{
|
||||
getPlayer().hurtResistantTime = 0;
|
||||
getPlayer().attackEntityFrom(BloodMagicAPI.getDamageSource(), 1.0F);
|
||||
}
|
||||
|
||||
} else if (syphon >= 100) {
|
||||
if (!getPlayer().capabilities.isCreativeMode) {
|
||||
for (int i = 0; i < ((syphon + 99) / 100); i++) {
|
||||
} else if (syphon >= 100)
|
||||
{
|
||||
if (!getPlayer().capabilities.isCreativeMode)
|
||||
{
|
||||
for (int i = 0; i < ((syphon + 99) / 100); i++)
|
||||
{
|
||||
getPlayer().hurtResistantTime = 0;
|
||||
getPlayer().attackEntityFrom(BloodMagicAPI.getDamageSource(), 1.0F);
|
||||
}
|
||||
|
|
|
@ -4,12 +4,15 @@ import WayofTime.bloodmagic.api.registry.OrbRegistry;
|
|||
|
||||
/**
|
||||
* Base object for all Blood Orbs. Makes Orb creation quite a bit easier.
|
||||
*
|
||||
* Just create a new BloodOrb instance then register it with {@link OrbRegistry#registerOrb(BloodOrb)}
|
||||
* This will allow the use of just one item ID for all orbs. If an addon dev needs more control over the intricacies
|
||||
* of their orb (custom right clicking, renderers, etc), they can just create their own item as normal.
|
||||
*
|
||||
* Just create a new BloodOrb instance then register it with
|
||||
* {@link OrbRegistry#registerOrb(BloodOrb)} This will allow the use of just one
|
||||
* item ID for all orbs. If an addon dev needs more control over the intricacies
|
||||
* of their orb (custom right clicking, renderers, etc), they can just create
|
||||
* their own item as normal.
|
||||
*/
|
||||
public class BloodOrb {
|
||||
public class BloodOrb
|
||||
{
|
||||
|
||||
private String name;
|
||||
private int tier;
|
||||
|
@ -17,52 +20,58 @@ public class BloodOrb {
|
|||
private String owner = "BloodMagic";
|
||||
|
||||
/**
|
||||
* A base object for BloodOrbs. A bit cleaner than the
|
||||
* old way through EnergyItems.
|
||||
*
|
||||
* @param name - A name for the Orb. Gets put into an unlocalized name.
|
||||
* @param tier - The tier of the Orb.
|
||||
* @param capacity - The max amount of LP the Orb can store.
|
||||
* A base object for BloodOrbs. A bit cleaner than the old way through
|
||||
* EnergyItems.
|
||||
*
|
||||
* @param name
|
||||
* - A name for the Orb. Gets put into an unlocalized name.
|
||||
* @param tier
|
||||
* - The tier of the Orb.
|
||||
* @param capacity
|
||||
* - The max amount of LP the Orb can store.
|
||||
*/
|
||||
public BloodOrb(String name, int tier, int capacity) {
|
||||
public BloodOrb(String name, int tier, int capacity)
|
||||
{
|
||||
this.name = name;
|
||||
this.tier = tier;
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getTier() {
|
||||
public int getTier()
|
||||
{
|
||||
return tier;
|
||||
}
|
||||
|
||||
public int getCapacity() {
|
||||
public int getCapacity()
|
||||
{
|
||||
return capacity;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
public String getOwner()
|
||||
{
|
||||
return owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* For setting the MODID of the mod that creates the Orb. Not required, but preferred.
|
||||
*
|
||||
* For setting the MODID of the mod that creates the Orb. Not required, but
|
||||
* preferred.
|
||||
*
|
||||
* @return - The BloodOrb object for further use.
|
||||
*/
|
||||
public BloodOrb setOwner(String owner) {
|
||||
public BloodOrb setOwner(String owner)
|
||||
{
|
||||
this.owner = owner;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BloodOrb{" +
|
||||
"name='" + name + '\'' +
|
||||
", tier=" + tier +
|
||||
", capacity=" + capacity +
|
||||
", owner=" + owner +
|
||||
'}';
|
||||
public String toString()
|
||||
{
|
||||
return "BloodOrb{" + "name='" + name + '\'' + ", tier=" + tier + ", capacity=" + capacity + ", owner=" + owner + '}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package WayofTime.bloodmagic.api.orb;
|
||||
|
||||
public interface IBloodOrb {
|
||||
public interface IBloodOrb
|
||||
{
|
||||
|
||||
BloodOrb getOrb(int meta);
|
||||
|
||||
|
|
|
@ -19,227 +19,281 @@ import WayofTime.bloodmagic.api.orb.IBloodOrb;
|
|||
/**
|
||||
* 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;
|
||||
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;
|
||||
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(Block result, Object... recipe)
|
||||
{
|
||||
this(new ItemStack(result), recipe);
|
||||
}
|
||||
|
||||
public ShapedBloodOrbRecipe(Item 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();
|
||||
public ShapedBloodOrbRecipe(ItemStack result, Object... recipe)
|
||||
{
|
||||
output = result.copy();
|
||||
|
||||
String shape = "";
|
||||
int idx = 0;
|
||||
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 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++]);
|
||||
if (recipe[idx] instanceof String[])
|
||||
{
|
||||
String[] parts = ((String[]) recipe[idx++]);
|
||||
|
||||
for (String s : parts) {
|
||||
width = s.length();
|
||||
shape += s;
|
||||
}
|
||||
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++;
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
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>();
|
||||
HashMap<Character, Object> itemMap = new HashMap<Character, Object>();
|
||||
|
||||
for (; idx < recipe.length; idx += 2) {
|
||||
Character chr = (Character) recipe[idx];
|
||||
Object in = recipe[idx + 1];
|
||||
for (; idx < recipe.length; idx += 2)
|
||||
{
|
||||
Character chr = (Character) recipe[idx];
|
||||
Object in = recipe[idx + 1];
|
||||
|
||||
if (in instanceof IBloodOrb || (in instanceof ItemStack && ((ItemStack) in).getItem() instanceof IBloodOrb)) {
|
||||
// If the item is an instanceof IBloodOrb then save the level of the orb.
|
||||
if (in instanceof ItemStack)
|
||||
itemMap.put(chr, ((IBloodOrb) ((ItemStack) in).getItem()).getOrbLevel(((ItemStack) in).getItemDamage()));
|
||||
else
|
||||
itemMap.put(chr, ((IBloodOrb) in).getOrbLevel(((ItemStack) in).getItemDamage()));
|
||||
} 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 orb recipe: ";
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
throw new RuntimeException(ret);
|
||||
}
|
||||
}
|
||||
if (in instanceof IBloodOrb || (in instanceof ItemStack && ((ItemStack) in).getItem() instanceof IBloodOrb))
|
||||
{
|
||||
// If the item is an instanceof IBloodOrb then save the level of
|
||||
// the orb.
|
||||
if (in instanceof ItemStack)
|
||||
itemMap.put(chr, ((IBloodOrb) ((ItemStack) in).getItem()).getOrbLevel(((ItemStack) in).getItemDamage()));
|
||||
else
|
||||
itemMap.put(chr, ((IBloodOrb) in).getOrbLevel(((ItemStack) in).getItemDamage()));
|
||||
} 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 orb 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);
|
||||
}
|
||||
}
|
||||
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;
|
||||
ShapedBloodOrbRecipe(ShapedRecipes recipe, Map<ItemStack, String> replacements)
|
||||
{
|
||||
output = recipe.getRecipeOutput();
|
||||
width = recipe.recipeWidth;
|
||||
height = recipe.recipeHeight;
|
||||
|
||||
input = new Object[recipe.recipeItems.length];
|
||||
input = new Object[recipe.recipeItems.length];
|
||||
|
||||
for (int i = 0; i < input.length; i++) {
|
||||
ItemStack ingred = recipe.recipeItems[i];
|
||||
for (int i = 0; i < input.length; i++)
|
||||
{
|
||||
ItemStack ingred = recipe.recipeItems[i];
|
||||
|
||||
if (ingred == null)
|
||||
continue;
|
||||
if (ingred == null)
|
||||
continue;
|
||||
|
||||
input[i] = recipe.recipeItems[i];
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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 ItemStack getCraftingResult(InventoryCrafting var1)
|
||||
{
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return input.length;
|
||||
}
|
||||
@Override
|
||||
public int getRecipeSize()
|
||||
{
|
||||
return input.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return output;
|
||||
}
|
||||
@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;
|
||||
}
|
||||
@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;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mirrored && checkMatch(inv, x, y, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
@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];
|
||||
}
|
||||
}
|
||||
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(slot.getItemDamage()) < (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;
|
||||
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(slot.getItemDamage()) < (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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!matched)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} else if (target == null && slot != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ShapedBloodOrbRecipe setMirrored(boolean mirror) {
|
||||
mirrored = mirror;
|
||||
return this;
|
||||
}
|
||||
public ShapedBloodOrbRecipe setMirrored(boolean mirror)
|
||||
{
|
||||
mirrored = mirror;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Object[] getInput() {
|
||||
return this.input;
|
||||
}
|
||||
public Object[] getInput()
|
||||
{
|
||||
return this.input;
|
||||
}
|
||||
|
||||
public ItemStack[] getRemainingItems(InventoryCrafting inv) {
|
||||
ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];
|
||||
public ItemStack[] getRemainingItems(InventoryCrafting inv)
|
||||
{
|
||||
ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < aitemstack.length; ++i) {
|
||||
ItemStack itemstack = inv.getStackInSlot(i);
|
||||
aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack);
|
||||
}
|
||||
for (int i = 0; i < aitemstack.length; ++i)
|
||||
{
|
||||
ItemStack itemstack = inv.getStackInSlot(i);
|
||||
aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack);
|
||||
}
|
||||
|
||||
return aitemstack;
|
||||
}
|
||||
return aitemstack;
|
||||
}
|
||||
}
|
|
@ -19,139 +19,173 @@ import WayofTime.bloodmagic.api.orb.IBloodOrb;
|
|||
/**
|
||||
* Shapeless Blood Orb Recipe Handler by joshie *
|
||||
*/
|
||||
public class ShapelessBloodOrbRecipe implements IRecipe {
|
||||
private ItemStack output = null;
|
||||
private ArrayList<Object> input = new ArrayList<Object>();
|
||||
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(Block result, Object... recipe)
|
||||
{
|
||||
this(new ItemStack(result), recipe);
|
||||
}
|
||||
|
||||
public ShapelessBloodOrbRecipe(Item 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) {
|
||||
if (((ItemStack) in).getItem() instanceof IBloodOrb) {
|
||||
input.add(((IBloodOrb) ((ItemStack) in).getItem()).getOrbLevel(((ItemStack) in).getItemDamage()));
|
||||
} else
|
||||
input.add(((ItemStack) in).copy());
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
public ShapelessBloodOrbRecipe(ItemStack result, Object... recipe)
|
||||
{
|
||||
output = result.copy();
|
||||
for (Object in : recipe)
|
||||
{
|
||||
if (in instanceof ItemStack)
|
||||
{
|
||||
if (((ItemStack) in).getItem() instanceof IBloodOrb)
|
||||
{
|
||||
input.add(((IBloodOrb) ((ItemStack) in).getItem()).getOrbLevel(((ItemStack) in).getItemDamage()));
|
||||
} else
|
||||
input.add(((ItemStack) in).copy());
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShapelessBloodOrbRecipe(ShapelessRecipes recipe, Map<ItemStack, String> replacements) {
|
||||
output = recipe.getRecipeOutput();
|
||||
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);
|
||||
}
|
||||
}
|
||||
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 int getRecipeSize()
|
||||
{
|
||||
return input.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return output;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting var1) {
|
||||
return output.copy();
|
||||
}
|
||||
@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);
|
||||
@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);
|
||||
for (int x = 0; x < var1.getSizeInventory(); x++)
|
||||
{
|
||||
ItemStack slot = var1.getStackInSlot(x);
|
||||
|
||||
if (slot != null) {
|
||||
boolean inRecipe = false;
|
||||
Iterator<Object> req = required.iterator();
|
||||
if (slot != null)
|
||||
{
|
||||
boolean inRecipe = false;
|
||||
Iterator<Object> req = required.iterator();
|
||||
|
||||
while (req.hasNext()) {
|
||||
boolean match = false;
|
||||
while (req.hasNext())
|
||||
{
|
||||
boolean match = false;
|
||||
|
||||
Object next = req.next();
|
||||
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(slot.getItemDamage()) < (Integer) next) {
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
return false;
|
||||
match = true;
|
||||
} 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 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(slot.getItemDamage()) < (Integer) next)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
return false;
|
||||
match = true;
|
||||
} 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 (match)
|
||||
{
|
||||
inRecipe = true;
|
||||
required.remove(next);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inRecipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!inRecipe)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return required.isEmpty();
|
||||
}
|
||||
return required.isEmpty();
|
||||
}
|
||||
|
||||
public ArrayList<Object> getInput() {
|
||||
return this.input;
|
||||
}
|
||||
public ArrayList<Object> getInput()
|
||||
{
|
||||
return this.input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getRemainingItems(InventoryCrafting inv) {
|
||||
ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];
|
||||
@Override
|
||||
public ItemStack[] getRemainingItems(InventoryCrafting inv)
|
||||
{
|
||||
ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < aitemstack.length; ++i) {
|
||||
ItemStack itemstack = inv.getStackInSlot(i);
|
||||
aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack);
|
||||
}
|
||||
for (int i = 0; i < aitemstack.length; ++i)
|
||||
{
|
||||
ItemStack itemstack = inv.getStackInSlot(i);
|
||||
aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack);
|
||||
}
|
||||
|
||||
return aitemstack;
|
||||
}
|
||||
return aitemstack;
|
||||
}
|
||||
}
|
|
@ -17,177 +17,212 @@ import com.google.common.collect.HashBiMap;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class AlchemyArrayRecipeRegistry {
|
||||
public class AlchemyArrayRecipeRegistry
|
||||
{
|
||||
|
||||
public static final AlchemyCircleRenderer defaultRenderer = new AlchemyCircleRenderer(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png"));
|
||||
public static final AlchemyCircleRenderer defaultRenderer = new AlchemyCircleRenderer(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png"));
|
||||
|
||||
@Getter
|
||||
private static BiMap<ItemStackWrapper, AlchemyArrayRecipe> recipes = HashBiMap.create();
|
||||
@Getter
|
||||
private static BiMap<ItemStackWrapper, AlchemyArrayRecipe> recipes = HashBiMap.create();
|
||||
|
||||
/**
|
||||
* General case for creating an AlchemyArrayEffect for a given input.
|
||||
*
|
||||
* @param inputStack
|
||||
* - Input item that is used to change the Alchemy Circle into
|
||||
* the circle that you are making
|
||||
* @param catalystStack
|
||||
* - Catalyst item that, when right-clicked onto the array, will
|
||||
* cause an effect
|
||||
* @param arrayEffect
|
||||
* - The effect that will be activated once the array is
|
||||
* activated
|
||||
* @param circleRenderer
|
||||
* - Circle rendered when the array is passive - can be
|
||||
* substituted for a special renderer
|
||||
*/
|
||||
public static void registerRecipe(ItemStack inputStack, @Nullable ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) {
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(inputStack)) {
|
||||
AlchemyArrayEffect eff = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||
if (eff != null) {
|
||||
return; // Recipe already exists!
|
||||
} else {
|
||||
arrayRecipe.catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
||||
if (circleRenderer != null) {
|
||||
arrayRecipe.circleRenderer = circleRenderer;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* General case for creating an AlchemyArrayEffect for a given input.
|
||||
*
|
||||
* @param inputStack
|
||||
* - Input item that is used to change the Alchemy Circle into
|
||||
* the circle that you are making
|
||||
* @param catalystStack
|
||||
* - Catalyst item that, when right-clicked onto the array, will
|
||||
* cause an effect
|
||||
* @param arrayEffect
|
||||
* - The effect that will be activated once the array is
|
||||
* activated
|
||||
* @param circleRenderer
|
||||
* - Circle rendered when the array is passive - can be
|
||||
* substituted for a special renderer
|
||||
*/
|
||||
public static void registerRecipe(ItemStack inputStack, @Nullable ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer)
|
||||
{
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet())
|
||||
{
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(inputStack))
|
||||
{
|
||||
AlchemyArrayEffect eff = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||
if (eff != null)
|
||||
{
|
||||
return; // Recipe already exists!
|
||||
} else
|
||||
{
|
||||
arrayRecipe.catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
||||
if (circleRenderer != null)
|
||||
{
|
||||
arrayRecipe.circleRenderer = circleRenderer;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (circleRenderer == null) {
|
||||
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, defaultRenderer));
|
||||
} else {
|
||||
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, circleRenderer));
|
||||
}
|
||||
if (circleRenderer == null)
|
||||
{
|
||||
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, defaultRenderer));
|
||||
} else
|
||||
{
|
||||
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, circleRenderer));
|
||||
}
|
||||
|
||||
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, circleRenderer));
|
||||
}
|
||||
recipes.put(ItemStackWrapper.getHolder(inputStack), new AlchemyArrayRecipe(inputStack, catalystStack, arrayEffect, circleRenderer));
|
||||
}
|
||||
|
||||
public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack, AlchemyCircleRenderer circleRenderer) {
|
||||
registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack), circleRenderer);
|
||||
}
|
||||
public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack, AlchemyCircleRenderer circleRenderer)
|
||||
{
|
||||
registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack), circleRenderer);
|
||||
}
|
||||
|
||||
public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource) {
|
||||
registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource);
|
||||
}
|
||||
public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack, ResourceLocation arrayResource)
|
||||
{
|
||||
registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack), arrayResource);
|
||||
}
|
||||
|
||||
public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack) {
|
||||
registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack));
|
||||
}
|
||||
public static void registerCraftingRecipe(ItemStack inputStack, ItemStack catalystStack, ItemStack outputStack)
|
||||
{
|
||||
registerRecipe(inputStack, catalystStack, new AlchemyArrayEffectCrafting(outputStack));
|
||||
}
|
||||
|
||||
public static void registerRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource) {
|
||||
AlchemyCircleRenderer circleRenderer = null;
|
||||
if (arrayResource == null) {
|
||||
circleRenderer = defaultRenderer;
|
||||
} else {
|
||||
circleRenderer = new AlchemyCircleRenderer(arrayResource);
|
||||
}
|
||||
public static void registerRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, ResourceLocation arrayResource)
|
||||
{
|
||||
AlchemyCircleRenderer circleRenderer = null;
|
||||
if (arrayResource == null)
|
||||
{
|
||||
circleRenderer = defaultRenderer;
|
||||
} else
|
||||
{
|
||||
circleRenderer = new AlchemyCircleRenderer(arrayResource);
|
||||
}
|
||||
|
||||
registerRecipe(inputStack, catalystStack, arrayEffect, circleRenderer);
|
||||
}
|
||||
registerRecipe(inputStack, catalystStack, arrayEffect, circleRenderer);
|
||||
}
|
||||
|
||||
public static void registerRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect) {
|
||||
registerRecipe(inputStack, catalystStack, arrayEffect, (AlchemyCircleRenderer) null);
|
||||
}
|
||||
public static void registerRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect)
|
||||
{
|
||||
registerRecipe(inputStack, catalystStack, arrayEffect, (AlchemyCircleRenderer) null);
|
||||
}
|
||||
|
||||
public static void replaceAlchemyCircle(ItemStack inputStack, AlchemyCircleRenderer circleRenderer) {
|
||||
if (circleRenderer == null) {
|
||||
return;
|
||||
}
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(inputStack)) {
|
||||
arrayRecipe.circleRenderer = circleRenderer;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void replaceAlchemyCircle(ItemStack inputStack, AlchemyCircleRenderer circleRenderer)
|
||||
{
|
||||
if (circleRenderer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet())
|
||||
{
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(inputStack))
|
||||
{
|
||||
arrayRecipe.circleRenderer = circleRenderer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static AlchemyArrayRecipe getRecipeForInput(ItemStack input) {
|
||||
return recipes.get(input);
|
||||
}
|
||||
public static AlchemyArrayRecipe getRecipeForInput(ItemStack input)
|
||||
{
|
||||
return recipes.get(input);
|
||||
}
|
||||
|
||||
public static AlchemyArrayEffect getAlchemyArrayEffect(ItemStack inputStack, @Nullable ItemStack catalystStack) {
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (ItemStackWrapper.getHolder(arrayRecipe.getInputStack()).equals(ItemStackWrapper.getHolder(inputStack))) {
|
||||
AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||
public static AlchemyArrayEffect getAlchemyArrayEffect(ItemStack inputStack, @Nullable ItemStack catalystStack)
|
||||
{
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet())
|
||||
{
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (ItemStackWrapper.getHolder(arrayRecipe.getInputStack()).equals(ItemStackWrapper.getHolder(inputStack)))
|
||||
{
|
||||
AlchemyArrayEffect effect = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
|
||||
|
||||
return effect; // TODO: Decide if a copy should be returned.
|
||||
}
|
||||
}
|
||||
return effect; // TODO: Decide if a copy should be returned.
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static AlchemyCircleRenderer getAlchemyCircleRenderer(ItemStack inputStack) {
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet()) {
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(inputStack)) {
|
||||
return arrayRecipe.circleRenderer;
|
||||
}
|
||||
}
|
||||
public static AlchemyCircleRenderer getAlchemyCircleRenderer(ItemStack inputStack)
|
||||
{
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayRecipe> entry : recipes.entrySet())
|
||||
{
|
||||
AlchemyArrayRecipe arrayRecipe = entry.getValue();
|
||||
if (arrayRecipe.doesInputMatchRecipe(inputStack))
|
||||
{
|
||||
return arrayRecipe.circleRenderer;
|
||||
}
|
||||
}
|
||||
|
||||
return defaultRenderer;
|
||||
}
|
||||
return defaultRenderer;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public static class AlchemyArrayRecipe {
|
||||
@Getter
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public static class AlchemyArrayRecipe
|
||||
{
|
||||
|
||||
public AlchemyCircleRenderer circleRenderer;
|
||||
public final ItemStack inputStack;
|
||||
public final BiMap<ItemStackWrapper, AlchemyArrayEffect> catalystMap = HashBiMap.create();
|
||||
public AlchemyCircleRenderer circleRenderer;
|
||||
public final ItemStack inputStack;
|
||||
public final BiMap<ItemStackWrapper, AlchemyArrayEffect> catalystMap = HashBiMap.create();
|
||||
|
||||
public AlchemyArrayRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) {
|
||||
this.inputStack = inputStack;
|
||||
|
||||
catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
||||
|
||||
this.circleRenderer = circleRenderer;
|
||||
}
|
||||
public AlchemyArrayRecipe(ItemStack inputStack, ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer)
|
||||
{
|
||||
this.inputStack = inputStack;
|
||||
|
||||
/**
|
||||
* Compares the inputed ItemStack to see if it matches with the recipe's
|
||||
* inputStack.
|
||||
*
|
||||
* @param comparedStack
|
||||
* @return - true if the ItemStack is a compatible item
|
||||
*/
|
||||
public boolean doesInputMatchRecipe(ItemStack comparedStack) {
|
||||
if (comparedStack == null || this.inputStack == null)
|
||||
return false;
|
||||
catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
|
||||
|
||||
return this.inputStack.isItemEqual(comparedStack);
|
||||
}
|
||||
this.circleRenderer = circleRenderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the actual AlchemyArrayEffect for the given catalyst.
|
||||
*
|
||||
* @param comparedStack
|
||||
* The catalyst that is being checked
|
||||
* @return
|
||||
*/
|
||||
public AlchemyArrayEffect getAlchemyArrayEffectForCatalyst(@Nullable ItemStack comparedStack) {
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayEffect> entry : catalystMap.entrySet()) {
|
||||
ItemStack catalystStack = entry.getKey().toStack();
|
||||
if (comparedStack == null && catalystStack == null) {
|
||||
return entry.getValue();
|
||||
}
|
||||
/**
|
||||
* Compares the inputed ItemStack to see if it matches with the recipe's
|
||||
* inputStack.
|
||||
*
|
||||
* @param comparedStack
|
||||
* @return - true if the ItemStack is a compatible item
|
||||
*/
|
||||
public boolean doesInputMatchRecipe(ItemStack comparedStack)
|
||||
{
|
||||
if (comparedStack == null || this.inputStack == null)
|
||||
return false;
|
||||
|
||||
if (comparedStack == null || catalystStack == null) {
|
||||
continue;
|
||||
}
|
||||
return this.inputStack.isItemEqual(comparedStack);
|
||||
}
|
||||
|
||||
if (catalystStack.isItemEqual(comparedStack)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the actual AlchemyArrayEffect for the given catalyst.
|
||||
*
|
||||
* @param comparedStack
|
||||
* The catalyst that is being checked
|
||||
* @return
|
||||
*/
|
||||
public AlchemyArrayEffect getAlchemyArrayEffectForCatalyst(@Nullable ItemStack comparedStack)
|
||||
{
|
||||
for (Entry<ItemStackWrapper, AlchemyArrayEffect> entry : catalystMap.entrySet())
|
||||
{
|
||||
ItemStack catalystStack = entry.getKey().toStack();
|
||||
if (comparedStack == null && catalystStack == null)
|
||||
{
|
||||
return entry.getValue();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (comparedStack == null || catalystStack == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (catalystStack.isItemEqual(comparedStack))
|
||||
{
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,26 +11,29 @@ import net.minecraft.item.ItemStack;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class AltarRecipeRegistry {
|
||||
|
||||
public class AltarRecipeRegistry
|
||||
{
|
||||
@Getter
|
||||
private static BiMap<ItemStack, AltarRecipe> recipes = HashBiMap.create();
|
||||
|
||||
public static void registerRecipe(AltarRecipe recipe) {
|
||||
public static void registerRecipe(AltarRecipe recipe)
|
||||
{
|
||||
if (!recipes.containsValue(recipe))
|
||||
recipes.put(recipe.input, recipe);
|
||||
else
|
||||
BloodMagicAPI.getLogger().error("Error adding altar recipe for %s. Recipe already exists.", recipe.input.getDisplayName(), recipe.output == null ? "" : " -> " );
|
||||
BloodMagicAPI.getLogger().error("Error adding altar recipe for %s. Recipe already exists.", recipe.input.getDisplayName(), recipe.output == null ? "" : " -> ");
|
||||
}
|
||||
|
||||
public static AltarRecipe getRecipeForInput(ItemStack input) {
|
||||
public static AltarRecipe getRecipeForInput(ItemStack input)
|
||||
{
|
||||
return recipes.get(input);
|
||||
}
|
||||
|
||||
@Getter
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public static class AltarRecipe {
|
||||
public static class AltarRecipe
|
||||
{
|
||||
|
||||
public final int syphon, consumeRate, drainRate;
|
||||
public final boolean useTag;
|
||||
|
@ -38,18 +41,29 @@ public class AltarRecipeRegistry {
|
|||
public final EnumAltarTier minTier;
|
||||
|
||||
/**
|
||||
* Allows creation of a recipe for the {@link WayofTime.bloodmagic.block.BlockAltar} / {@link WayofTime.bloodmagic.tile.TileAltar}.
|
||||
* The output ItemStack is allowed to be null as some recipes do not contain an output. (Blood Orbs)
|
||||
*
|
||||
* @param input - The input ItemStack
|
||||
* @param output - The ItemStack obtained from the recipe
|
||||
* @param minTier - The minimum tier of Altar required
|
||||
* @param syphon - The amount of LP to syphon from the Altar
|
||||
* @param consumeRate - The rate at which LP is consumed during crafting
|
||||
* @param drainRate - The rate at which LP is drained during crafting
|
||||
* @param useTag -
|
||||
* Allows creation of a recipe for the
|
||||
* {@link WayofTime.bloodmagic.block.BlockAltar} /
|
||||
* {@link WayofTime.bloodmagic.tile.TileAltar}. The output ItemStack is
|
||||
* allowed to be null as some recipes do not contain an output. (Blood
|
||||
* Orbs)
|
||||
*
|
||||
* @param input
|
||||
* - The input ItemStack
|
||||
* @param output
|
||||
* - The ItemStack obtained from the recipe
|
||||
* @param minTier
|
||||
* - The minimum tier of Altar required
|
||||
* @param syphon
|
||||
* - The amount of LP to syphon from the Altar
|
||||
* @param consumeRate
|
||||
* - The rate at which LP is consumed during crafting
|
||||
* @param drainRate
|
||||
* - The rate at which LP is drained during crafting
|
||||
* @param useTag
|
||||
* -
|
||||
*/
|
||||
public AltarRecipe(ItemStack input, @Nullable ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean useTag) {
|
||||
public AltarRecipe(ItemStack input, @Nullable ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean useTag)
|
||||
{
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.minTier = minTier;
|
||||
|
@ -59,19 +73,27 @@ public class AltarRecipeRegistry {
|
|||
this.useTag = useTag;
|
||||
}
|
||||
|
||||
public AltarRecipe(ItemStack input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) {
|
||||
public AltarRecipe(ItemStack input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate)
|
||||
{
|
||||
this(input, output, minTier, syphon, consumeRate, drainRate, false);
|
||||
}
|
||||
|
||||
public AltarRecipe(ItemStack input, EnumAltarTier minTier, int consumeRate, int drainRate) {
|
||||
public AltarRecipe(ItemStack input, EnumAltarTier minTier, int consumeRate, int drainRate)
|
||||
{
|
||||
this(input, null, minTier, 0, consumeRate, drainRate);
|
||||
}
|
||||
|
||||
public boolean doesRequiredItemMatch(ItemStack comparedStack, EnumAltarTier tierCheck) {
|
||||
|
||||
public boolean doesRequiredItemMatch(ItemStack comparedStack, EnumAltarTier tierCheck)
|
||||
{
|
||||
if (comparedStack == null || this.input == null)
|
||||
return false;
|
||||
|
||||
return tierCheck.ordinal() >= minTier.ordinal() && this.input.isItemEqual(comparedStack);// && (this.useTag ? this.areRequiredTagsEqual(comparedStack) : true);
|
||||
return tierCheck.ordinal() >= minTier.ordinal() && this.input.isItemEqual(comparedStack);// &&
|
||||
// (this.useTag
|
||||
// ?
|
||||
// this.areRequiredTagsEqual(comparedStack)
|
||||
// :
|
||||
// true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,19 +10,24 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ImperfectRitualRegistry {
|
||||
public class ImperfectRitualRegistry
|
||||
{
|
||||
|
||||
public static final Map<ImperfectRitual, Boolean> enabledRituals = new HashMap<ImperfectRitual, Boolean>();
|
||||
private static final BiMap<String, ImperfectRitual> registry = HashBiMap.create();
|
||||
|
||||
/**
|
||||
* The safe way to register a new Ritual.
|
||||
*
|
||||
* @param imperfectRitual - The imperfect ritual to register.
|
||||
* @param id - The ID for the imperfect ritual. Cannot be duplicated.
|
||||
*
|
||||
* @param imperfectRitual
|
||||
* - The imperfect ritual to register.
|
||||
* @param id
|
||||
* - The ID for the imperfect ritual. Cannot be duplicated.
|
||||
*/
|
||||
public static void registerRitual(ImperfectRitual imperfectRitual, String id) {
|
||||
if (imperfectRitual != null) {
|
||||
public static void registerRitual(ImperfectRitual imperfectRitual, String id)
|
||||
{
|
||||
if (imperfectRitual != null)
|
||||
{
|
||||
if (registry.containsKey(id))
|
||||
BloodMagicAPI.getLogger().error("Duplicate imperfect ritual id: %s", id);
|
||||
else
|
||||
|
@ -30,11 +35,13 @@ public class ImperfectRitualRegistry {
|
|||
}
|
||||
}
|
||||
|
||||
public static void registerRitual(ImperfectRitual imperfectRitual) {
|
||||
public static void registerRitual(ImperfectRitual imperfectRitual)
|
||||
{
|
||||
registerRitual(imperfectRitual, imperfectRitual.getName());
|
||||
}
|
||||
|
||||
public static ImperfectRitual getRitualForBlock(BlockStack blockStack) {
|
||||
public static ImperfectRitual getRitualForBlock(BlockStack blockStack)
|
||||
{
|
||||
for (ImperfectRitual imperfectRitual : getRegistry().values())
|
||||
if (imperfectRitual.getRequiredBlock().equals(blockStack))
|
||||
return imperfectRitual;
|
||||
|
@ -42,44 +49,55 @@ public class ImperfectRitualRegistry {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static ImperfectRitual getRitualForId(String id) {
|
||||
public static ImperfectRitual getRitualForId(String id)
|
||||
{
|
||||
return registry.get(id);
|
||||
}
|
||||
|
||||
public static String getIdForRitual(ImperfectRitual imperfectRitual) {
|
||||
public static String getIdForRitual(ImperfectRitual imperfectRitual)
|
||||
{
|
||||
return registry.inverse().get(imperfectRitual);
|
||||
}
|
||||
|
||||
public static boolean isMapEmpty() {
|
||||
public static boolean isMapEmpty()
|
||||
{
|
||||
return registry.isEmpty();
|
||||
}
|
||||
|
||||
public static int getMapSize() {
|
||||
public static int getMapSize()
|
||||
{
|
||||
return registry.size();
|
||||
}
|
||||
|
||||
public static boolean ritualEnabled(ImperfectRitual imperfectRitual) {
|
||||
try {
|
||||
public static boolean ritualEnabled(ImperfectRitual imperfectRitual)
|
||||
{
|
||||
try
|
||||
{
|
||||
return enabledRituals.get(imperfectRitual);
|
||||
} catch (NullPointerException e) {
|
||||
} catch (NullPointerException e)
|
||||
{
|
||||
BloodMagicAPI.getLogger().error("Invalid Imperfect Ritual was called");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static BiMap<String, ImperfectRitual> getRegistry() {
|
||||
public static BiMap<String, ImperfectRitual> getRegistry()
|
||||
{
|
||||
return HashBiMap.create(registry);
|
||||
}
|
||||
|
||||
public static BiMap<ImperfectRitual, Boolean> getEnabledMap() {
|
||||
public static BiMap<ImperfectRitual, Boolean> getEnabledMap()
|
||||
{
|
||||
return HashBiMap.create(enabledRituals);
|
||||
}
|
||||
|
||||
public static ArrayList<String> getIds() {
|
||||
public static ArrayList<String> getIds()
|
||||
{
|
||||
return new ArrayList<String>(registry.keySet());
|
||||
}
|
||||
|
||||
public static ArrayList<ImperfectRitual> getRituals() {
|
||||
public static ArrayList<ImperfectRitual> getRituals()
|
||||
{
|
||||
return new ArrayList<ImperfectRitual>(registry.values());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,15 +14,17 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This is only for those who wish to add a basic {@link BloodOrb}. If you need custom handling,
|
||||
* you will need your own item class.
|
||||
* This is only for those who wish to add a basic {@link BloodOrb}. If you need
|
||||
* custom handling, you will need your own item class.
|
||||
*/
|
||||
public class OrbRegistry {
|
||||
public class OrbRegistry
|
||||
{
|
||||
|
||||
@Getter
|
||||
private static List<BloodOrb> orbs = new ArrayList<BloodOrb>();
|
||||
|
||||
public static void registerOrb(BloodOrb orb) {
|
||||
public static void registerOrb(BloodOrb orb)
|
||||
{
|
||||
if (!orbs.contains(orb))
|
||||
orbs.add(orb);
|
||||
else
|
||||
|
@ -30,30 +32,36 @@ public class OrbRegistry {
|
|||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void registerOrbTexture(BloodOrb orb, String resourceLocation) {
|
||||
public static void registerOrbTexture(BloodOrb orb, String resourceLocation)
|
||||
{
|
||||
int meta = getIndexOf(orb);
|
||||
|
||||
ModelBakery.addVariantName(BloodMagicAPI.getItem(BloodMagicAPI.ORB), resourceLocation);
|
||||
ModelLoader.setCustomModelResourceLocation(BloodMagicAPI.getItem(BloodMagicAPI.ORB), meta, new ModelResourceLocation(resourceLocation, "inventory"));
|
||||
}
|
||||
|
||||
public static BloodOrb getOrb(int index) {
|
||||
public static BloodOrb getOrb(int index)
|
||||
{
|
||||
return orbs.get(index);
|
||||
}
|
||||
|
||||
public static int getIndexOf(BloodOrb orb) {
|
||||
public static int getIndexOf(BloodOrb orb)
|
||||
{
|
||||
return orbs.indexOf(orb);
|
||||
}
|
||||
|
||||
public static boolean isEmpty() {
|
||||
public static boolean isEmpty()
|
||||
{
|
||||
return orbs.isEmpty();
|
||||
}
|
||||
|
||||
public static int getSize() {
|
||||
public static int getSize()
|
||||
{
|
||||
return orbs.size();
|
||||
}
|
||||
|
||||
public static ItemStack getOrbStack(BloodOrb orb) {
|
||||
public static ItemStack getOrbStack(BloodOrb orb)
|
||||
{
|
||||
return new ItemStack(BloodMagicAPI.getItem(BloodMagicAPI.ORB), 1, getIndexOf(orb));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,72 +10,91 @@ import WayofTime.bloodmagic.api.ritual.Ritual;
|
|||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
|
||||
public class RitualRegistry {
|
||||
public class RitualRegistry
|
||||
{
|
||||
|
||||
public static final Map<Ritual, Boolean> enabledRituals = new HashMap<Ritual, Boolean>();
|
||||
private static final BiMap<String, Ritual> registry = HashBiMap.create();
|
||||
// Ordered list for actions that depend on the order that the rituals were registered in
|
||||
private static final ArrayList<String> orderedIdList = new ArrayList<String>();
|
||||
// Ordered list for actions that depend on the order that the rituals were
|
||||
// registered in
|
||||
private static final ArrayList<String> orderedIdList = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* The safe way to register a new Ritual.
|
||||
*
|
||||
* @param ritual - The ritual to register.
|
||||
* @param id - The ID for the ritual. Cannot be duplicated.
|
||||
*
|
||||
* @param ritual
|
||||
* - The ritual to register.
|
||||
* @param id
|
||||
* - The ID for the ritual. Cannot be duplicated.
|
||||
*/
|
||||
public static void registerRitual(Ritual ritual, String id) {
|
||||
if (ritual != null) {
|
||||
public static void registerRitual(Ritual ritual, String id)
|
||||
{
|
||||
if (ritual != null)
|
||||
{
|
||||
if (registry.containsKey(id))
|
||||
BloodMagicAPI.getLogger().error("Duplicate ritual id: %s", id);
|
||||
else {
|
||||
else
|
||||
{
|
||||
registry.put(id, ritual);
|
||||
orderedIdList.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Ritual getRitualForId(String id) {
|
||||
public static Ritual getRitualForId(String id)
|
||||
{
|
||||
return registry.get(id);
|
||||
}
|
||||
|
||||
public static String getIdForRitual(Ritual ritual) {
|
||||
public static String getIdForRitual(Ritual ritual)
|
||||
{
|
||||
return registry.inverse().get(ritual);
|
||||
}
|
||||
|
||||
public static boolean isMapEmpty() {
|
||||
public static boolean isMapEmpty()
|
||||
{
|
||||
return registry.isEmpty();
|
||||
}
|
||||
|
||||
public static int getMapSize() {
|
||||
public static int getMapSize()
|
||||
{
|
||||
return registry.size();
|
||||
}
|
||||
|
||||
public static boolean ritualEnabled(Ritual ritual) {
|
||||
try {
|
||||
public static boolean ritualEnabled(Ritual ritual)
|
||||
{
|
||||
try
|
||||
{
|
||||
return enabledRituals.get(ritual);
|
||||
} catch (NullPointerException e) {
|
||||
} catch (NullPointerException e)
|
||||
{
|
||||
BloodMagicAPI.getLogger().error("Invalid Ritual was called");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static BiMap<String, Ritual> getRegistry() {
|
||||
public static BiMap<String, Ritual> getRegistry()
|
||||
{
|
||||
return HashBiMap.create(registry);
|
||||
}
|
||||
|
||||
public static Map<Ritual, Boolean> getEnabledMap() {
|
||||
public static Map<Ritual, Boolean> getEnabledMap()
|
||||
{
|
||||
return new HashMap<Ritual, Boolean>(enabledRituals);
|
||||
}
|
||||
|
||||
public static ArrayList<String> getIds() {
|
||||
public static ArrayList<String> getIds()
|
||||
{
|
||||
return new ArrayList<String>(registry.keySet());
|
||||
}
|
||||
|
||||
public static ArrayList<String> getOrderedIds() {
|
||||
return orderedIdList;
|
||||
|
||||
public static ArrayList<String> getOrderedIds()
|
||||
{
|
||||
return orderedIdList;
|
||||
}
|
||||
|
||||
public static ArrayList<Ritual> getRituals() {
|
||||
public static ArrayList<Ritual> getRituals()
|
||||
{
|
||||
return new ArrayList<Ritual>(registry.values());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,16 @@ import java.util.List;
|
|||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
||||
public class AreaDescriptor {
|
||||
|
||||
public List<BlockPos> getContainedPositions() {
|
||||
return new ArrayList();
|
||||
}
|
||||
|
||||
public AxisAlignedBB getAABB() {
|
||||
return null;
|
||||
}
|
||||
public class AreaDescriptor
|
||||
{
|
||||
|
||||
public List<BlockPos> getContainedPositions()
|
||||
{
|
||||
return new ArrayList();
|
||||
}
|
||||
|
||||
public AxisAlignedBB getAABB()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,34 +6,33 @@ import net.minecraft.util.IStringSerializable;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumRuneType implements IStringSerializable {
|
||||
public enum EnumRuneType implements IStringSerializable
|
||||
{
|
||||
|
||||
BLANK,
|
||||
WATER,
|
||||
FIRE,
|
||||
EARTH,
|
||||
AIR,
|
||||
DUSK,
|
||||
DAWN;
|
||||
BLANK, WATER, FIRE, EARTH, AIR, DUSK, DAWN;
|
||||
|
||||
public static EnumRuneType byMetadata(int meta) {
|
||||
public static EnumRuneType byMetadata(int meta)
|
||||
{
|
||||
if (meta < 0 || meta >= values().length)
|
||||
meta = 0;
|
||||
|
||||
return values()[meta];
|
||||
}
|
||||
|
||||
public ItemStack getScribeStack() {
|
||||
public ItemStack getScribeStack()
|
||||
{
|
||||
return new ItemStack(BloodMagicAPI.getItem(BloodMagicAPI.SCRIBE), 1, ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public String toString()
|
||||
{
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String getName()
|
||||
{
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,10 +8,11 @@ import net.minecraft.world.World;
|
|||
|
||||
/**
|
||||
* This interface is for internal implementation only.
|
||||
*
|
||||
*
|
||||
* It is provided via the API for easy obtaining of basic data.
|
||||
*/
|
||||
public interface IMasterRitualStone {
|
||||
public interface IMasterRitualStone
|
||||
{
|
||||
|
||||
String getOwner();
|
||||
|
||||
|
|
|
@ -5,14 +5,16 @@ import net.minecraft.world.World;
|
|||
|
||||
/**
|
||||
* This interface is for internal implementation only.
|
||||
*
|
||||
*
|
||||
* It is provided via the API for easy obtaining of basic data.
|
||||
*/
|
||||
public interface IRitualStone {
|
||||
public interface IRitualStone
|
||||
{
|
||||
|
||||
boolean isRuneType(World world, BlockPos pos, EnumRuneType runeType);
|
||||
|
||||
interface Tile {
|
||||
interface Tile
|
||||
{
|
||||
boolean isRuneType(EnumRuneType runeType);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,140 +21,152 @@ import net.minecraft.world.World;
|
|||
@RequiredArgsConstructor
|
||||
@EqualsAndHashCode(exclude = { "modableRangeMap" })
|
||||
@ToString
|
||||
public abstract class Ritual {
|
||||
public abstract class Ritual
|
||||
{
|
||||
|
||||
public final ArrayList<RitualComponent> ritualComponents = new ArrayList<RitualComponent>();
|
||||
private final String name;
|
||||
private final int crystalLevel;
|
||||
private final int activationCost;
|
||||
private final RitualRenderer renderer;
|
||||
private final String unlocalizedName;
|
||||
public final ArrayList<RitualComponent> ritualComponents = new ArrayList<RitualComponent>();
|
||||
private final String name;
|
||||
private final int crystalLevel;
|
||||
private final int activationCost;
|
||||
private final RitualRenderer renderer;
|
||||
private final String unlocalizedName;
|
||||
|
||||
private final Map<String, BlockPos[]> modableRangeMap = new HashMap<String, BlockPos[]>();
|
||||
private final Map<String, BlockPos[]> modableRangeMap = new HashMap<String, BlockPos[]>();
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* - The name of the ritual
|
||||
* @param crystalLevel
|
||||
* - Required Activation Crystal tier
|
||||
* @param activationCost
|
||||
* - Base LP cost for activating the ritual
|
||||
*/
|
||||
public Ritual(String name, int crystalLevel, int activationCost, String unlocalizedName) {
|
||||
this(name, crystalLevel, activationCost, null, unlocalizedName);
|
||||
}
|
||||
/**
|
||||
* @param name
|
||||
* - The name of the ritual
|
||||
* @param crystalLevel
|
||||
* - Required Activation Crystal tier
|
||||
* @param activationCost
|
||||
* - Base LP cost for activating the ritual
|
||||
*/
|
||||
public Ritual(String name, int crystalLevel, int activationCost, String unlocalizedName)
|
||||
{
|
||||
this(name, crystalLevel, activationCost, null, unlocalizedName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the player attempts to activate the ritual.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#activateRitual(ItemStack, EntityPlayer, Ritual)}
|
||||
*
|
||||
* @param masterRitualStone
|
||||
* - The {@link IMasterRitualStone} that the ritual is bound to
|
||||
* @param player
|
||||
* - The activating player
|
||||
* @return - Whether activation was successful
|
||||
*/
|
||||
public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Called when the player attempts to activate the ritual.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#activateRitual(ItemStack, EntityPlayer, Ritual)}
|
||||
*
|
||||
* @param masterRitualStone
|
||||
* - The {@link IMasterRitualStone} that the ritual is bound to
|
||||
* @param player
|
||||
* - The activating player
|
||||
* @return - Whether activation was successful
|
||||
*/
|
||||
public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called every {@link #getRefreshTime()} ticks while active.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, BlockPos)}
|
||||
*
|
||||
* @param masterRitualStone
|
||||
* - The {@link IMasterRitualStone} that the ritual is bound to
|
||||
*/
|
||||
public abstract void performRitual(IMasterRitualStone masterRitualStone);
|
||||
/**
|
||||
* Called every {@link #getRefreshTime()} ticks while active.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, BlockPos)}
|
||||
*
|
||||
* @param masterRitualStone
|
||||
* - The {@link IMasterRitualStone} that the ritual is bound to
|
||||
*/
|
||||
public abstract void performRitual(IMasterRitualStone masterRitualStone);
|
||||
|
||||
/**
|
||||
* Called when the ritual is stopped for a given {@link BreakType}.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(BreakType)}
|
||||
*
|
||||
* @param masterRitualStone
|
||||
* - The {@link IMasterRitualStone} that the ritual is bound to
|
||||
* @param breakType
|
||||
* - The type of break that caused the stoppage.
|
||||
*/
|
||||
public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType) {
|
||||
/**
|
||||
* Called when the ritual is stopped for a given {@link BreakType}.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(BreakType)}
|
||||
*
|
||||
* @param masterRitualStone
|
||||
* - The {@link IMasterRitualStone} that the ritual is bound to
|
||||
* @param breakType
|
||||
* - The type of break that caused the stoppage.
|
||||
*/
|
||||
public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to set the amount of LP drained every {@link #getRefreshTime()}
|
||||
* ticks.
|
||||
*
|
||||
* @return - The amount of LP drained per refresh
|
||||
*/
|
||||
public abstract int getRefreshCost();
|
||||
/**
|
||||
* Used to set the amount of LP drained every {@link #getRefreshTime()}
|
||||
* ticks.
|
||||
*
|
||||
* @return - The amount of LP drained per refresh
|
||||
*/
|
||||
public abstract int getRefreshCost();
|
||||
|
||||
/**
|
||||
* Used to set the refresh rate of the ritual. (How often
|
||||
* {@link #performRitual(IMasterRitualStone)} is called.
|
||||
*
|
||||
* @return - How often to perform the effect in ticks.
|
||||
*/
|
||||
public int getRefreshTime() {
|
||||
return 20;
|
||||
}
|
||||
/**
|
||||
* Used to set the refresh rate of the ritual. (How often
|
||||
* {@link #performRitual(IMasterRitualStone)} is called.
|
||||
*
|
||||
* @return - How often to perform the effect in ticks.
|
||||
*/
|
||||
public int getRefreshTime()
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
public void addBlockRange(String range, BlockPos[] defaultRange) {
|
||||
modableRangeMap.put(range, defaultRange);
|
||||
}
|
||||
public void addBlockRange(String range, BlockPos[] defaultRange)
|
||||
{
|
||||
modableRangeMap.put(range, defaultRange);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to grab the range of a ritual for a given effect. The order of the
|
||||
* blockPos array is: bottom corner, top corner.
|
||||
*
|
||||
* @param range
|
||||
* - Range that needs to be pulled.
|
||||
* @return - The range of the ritual effect. Array must be of size 2 and
|
||||
* have non-null values, with the first BlockPos having the lower
|
||||
* offset values and the second BlockPos having the higher offset
|
||||
* values
|
||||
*/
|
||||
public BlockPos[] getBlockRange(String range) {
|
||||
if (modableRangeMap.containsKey(range)) {
|
||||
return modableRangeMap.get(range);
|
||||
}
|
||||
|
||||
return new BlockPos[] { new BlockPos(0, 0, 0), new BlockPos(0, 0, 0) };
|
||||
}
|
||||
/**
|
||||
* Used to grab the range of a ritual for a given effect. The order of the
|
||||
* blockPos array is: bottom corner, top corner.
|
||||
*
|
||||
* @param range
|
||||
* - Range that needs to be pulled.
|
||||
* @return - The range of the ritual effect. Array must be of size 2 and
|
||||
* have non-null values, with the first BlockPos having the lower
|
||||
* offset values and the second BlockPos having the higher offset
|
||||
* values
|
||||
*/
|
||||
public BlockPos[] getBlockRange(String range)
|
||||
{
|
||||
if (modableRangeMap.containsKey(range))
|
||||
{
|
||||
return modableRangeMap.get(range);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of {@link RitualComponent} for checking the ritual.
|
||||
*/
|
||||
public abstract ArrayList<RitualComponent> getComponents();
|
||||
return new BlockPos[] { new BlockPos(0, 0, 0), new BlockPos(0, 0, 0) };
|
||||
}
|
||||
|
||||
public void addOffsetRunes(ArrayList<RitualComponent> components, int offset1, int offset2, int y, EnumRuneType rune) {
|
||||
components.add(new RitualComponent(new BlockPos(offset1, y, offset2), rune));
|
||||
components.add(new RitualComponent(new BlockPos(offset2, y, offset1), rune));
|
||||
components.add(new RitualComponent(new BlockPos(offset1, y, -offset2), rune));
|
||||
components.add(new RitualComponent(new BlockPos(-offset2, y, offset1), rune));
|
||||
components.add(new RitualComponent(new BlockPos(-offset1, y, offset2), rune));
|
||||
components.add(new RitualComponent(new BlockPos(offset2, y, -offset1), rune));
|
||||
components.add(new RitualComponent(new BlockPos(-offset1, y, -offset2), rune));
|
||||
components.add(new RitualComponent(new BlockPos(-offset2, y, -offset1), rune));
|
||||
}
|
||||
/**
|
||||
* @return a list of {@link RitualComponent} for checking the ritual.
|
||||
*/
|
||||
public abstract ArrayList<RitualComponent> getComponents();
|
||||
|
||||
public void addCornerRunes(ArrayList<RitualComponent> components, int offset, int y, EnumRuneType rune) {
|
||||
components.add(new RitualComponent(new BlockPos(offset, y, offset), rune));
|
||||
components.add(new RitualComponent(new BlockPos(offset, y, -offset), rune));
|
||||
components.add(new RitualComponent(new BlockPos(-offset, y, -offset), rune));
|
||||
components.add(new RitualComponent(new BlockPos(-offset, y, offset), rune));
|
||||
}
|
||||
public void addOffsetRunes(ArrayList<RitualComponent> components, int offset1, int offset2, int y, EnumRuneType rune)
|
||||
{
|
||||
components.add(new RitualComponent(new BlockPos(offset1, y, offset2), rune));
|
||||
components.add(new RitualComponent(new BlockPos(offset2, y, offset1), rune));
|
||||
components.add(new RitualComponent(new BlockPos(offset1, y, -offset2), rune));
|
||||
components.add(new RitualComponent(new BlockPos(-offset2, y, offset1), rune));
|
||||
components.add(new RitualComponent(new BlockPos(-offset1, y, offset2), rune));
|
||||
components.add(new RitualComponent(new BlockPos(offset2, y, -offset1), rune));
|
||||
components.add(new RitualComponent(new BlockPos(-offset1, y, -offset2), rune));
|
||||
components.add(new RitualComponent(new BlockPos(-offset2, y, -offset1), rune));
|
||||
}
|
||||
|
||||
public void addParallelRunes(ArrayList<RitualComponent> components, int offset, int y, EnumRuneType rune) {
|
||||
components.add(new RitualComponent(new BlockPos(offset, y, 0), rune));
|
||||
components.add(new RitualComponent(new BlockPos(-offset, y, 0), rune));
|
||||
components.add(new RitualComponent(new BlockPos(0, y, -offset), rune));
|
||||
components.add(new RitualComponent(new BlockPos(0, y, offset), rune));
|
||||
}
|
||||
public void addCornerRunes(ArrayList<RitualComponent> components, int offset, int y, EnumRuneType rune)
|
||||
{
|
||||
components.add(new RitualComponent(new BlockPos(offset, y, offset), rune));
|
||||
components.add(new RitualComponent(new BlockPos(offset, y, -offset), rune));
|
||||
components.add(new RitualComponent(new BlockPos(-offset, y, -offset), rune));
|
||||
components.add(new RitualComponent(new BlockPos(-offset, y, offset), rune));
|
||||
}
|
||||
|
||||
public enum BreakType {
|
||||
REDSTONE, BREAK_MRS, BREAK_STONE, ACTIVATE, DEACTIVATE, EXPLOSION,
|
||||
}
|
||||
public void addParallelRunes(ArrayList<RitualComponent> components, int offset, int y, EnumRuneType rune)
|
||||
{
|
||||
components.add(new RitualComponent(new BlockPos(offset, y, 0), rune));
|
||||
components.add(new RitualComponent(new BlockPos(-offset, y, 0), rune));
|
||||
components.add(new RitualComponent(new BlockPos(0, y, -offset), rune));
|
||||
components.add(new RitualComponent(new BlockPos(0, y, offset), rune));
|
||||
}
|
||||
|
||||
public enum BreakType
|
||||
{
|
||||
REDSTONE, BREAK_MRS, BREAK_STONE, ACTIVATE, DEACTIVATE, EXPLOSION,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,43 +6,49 @@ import net.minecraft.util.BlockPos;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
/**
|
||||
* Used to set a {@link EnumRuneType} type to a given {@link BlockPos}
|
||||
* for usage in Ritual creation.
|
||||
* Used to set a {@link EnumRuneType} type to a given {@link BlockPos} for usage
|
||||
* in Ritual creation.
|
||||
*/
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public class RitualComponent {
|
||||
public class RitualComponent
|
||||
{
|
||||
|
||||
private final BlockPos offset;
|
||||
private final EnumRuneType runeType;
|
||||
|
||||
public int getX(EnumFacing direction) {
|
||||
switch (direction) {
|
||||
case EAST:
|
||||
return -this.getOffset().getZ();
|
||||
case SOUTH:
|
||||
return -this.getOffset().getX();
|
||||
case WEST:
|
||||
return this.getOffset().getZ();
|
||||
default:
|
||||
return this.getOffset().getX();
|
||||
public int getX(EnumFacing direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case EAST:
|
||||
return -this.getOffset().getZ();
|
||||
case SOUTH:
|
||||
return -this.getOffset().getX();
|
||||
case WEST:
|
||||
return this.getOffset().getZ();
|
||||
default:
|
||||
return this.getOffset().getX();
|
||||
}
|
||||
}
|
||||
|
||||
public int getZ(EnumFacing direction) {
|
||||
switch (direction) {
|
||||
case EAST:
|
||||
return this.getOffset().getX();
|
||||
case SOUTH:
|
||||
return -this.getOffset().getZ();
|
||||
case WEST:
|
||||
return -this.getOffset().getX();
|
||||
default:
|
||||
return this.getOffset().getZ();
|
||||
public int getZ(EnumFacing direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case EAST:
|
||||
return this.getOffset().getX();
|
||||
case SOUTH:
|
||||
return -this.getOffset().getZ();
|
||||
case WEST:
|
||||
return -this.getOffset().getX();
|
||||
default:
|
||||
return this.getOffset().getZ();
|
||||
}
|
||||
}
|
||||
|
||||
public BlockPos getOffset(EnumFacing direction) {
|
||||
return new BlockPos(getX(direction), offset.getY(), getZ(direction));
|
||||
|
||||
public BlockPos getOffset(EnumFacing direction)
|
||||
{
|
||||
return new BlockPos(getX(direction), offset.getY(), getZ(direction));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,13 @@ package WayofTime.bloodmagic.api.ritual;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public abstract class RitualRenderer {
|
||||
public abstract class RitualRenderer
|
||||
{
|
||||
|
||||
public abstract void renderAt(IMasterRitualStone masterRitualStone, double x, double y, double z);
|
||||
|
||||
protected void bindTexture(ResourceLocation resourceLocation) {
|
||||
protected void bindTexture(ResourceLocation resourceLocation)
|
||||
{
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,11 @@ import net.minecraft.world.World;
|
|||
|
||||
/**
|
||||
* This interface is for internal implementation only.
|
||||
*
|
||||
*
|
||||
* It is provided via the API for easy obtaining of basic data.
|
||||
*/
|
||||
public interface IImperfectRitualStone {
|
||||
public interface IImperfectRitualStone
|
||||
{
|
||||
|
||||
boolean performRitual(World world, BlockPos pos, ImperfectRitual imperfectRitual, EntityPlayer player);
|
||||
|
||||
|
|
|
@ -9,13 +9,15 @@ import net.minecraft.util.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Abstract class for creating new imperfect rituals. ImperfectRituals need be registered with
|
||||
* Abstract class for creating new imperfect rituals. ImperfectRituals need be
|
||||
* registered with
|
||||
* {@link WayofTime.bloodmagic.api.registry.ImperfectRitualRegistry#registerRitual(ImperfectRitual)}
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
public abstract class ImperfectRitual {
|
||||
public abstract class ImperfectRitual
|
||||
{
|
||||
|
||||
private final String name;
|
||||
private final BlockStack requiredBlock;
|
||||
|
@ -23,26 +25,34 @@ public abstract class ImperfectRitual {
|
|||
private final boolean lightshow;
|
||||
|
||||
/**
|
||||
* @param name - The name of the ritual
|
||||
* @param requiredBlock - The block required above the ImperfectRitualStone
|
||||
* @param activationCost - Base LP cost for activating the ritual
|
||||
* @param name
|
||||
* - The name of the ritual
|
||||
* @param requiredBlock
|
||||
* - The block required above the ImperfectRitualStone
|
||||
* @param activationCost
|
||||
* - Base LP cost for activating the ritual
|
||||
*/
|
||||
public ImperfectRitual(String name, BlockStack requiredBlock, int activationCost) {
|
||||
public ImperfectRitual(String name, BlockStack requiredBlock, int activationCost)
|
||||
{
|
||||
this(name, requiredBlock, activationCost, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the player activates the ritual
|
||||
* {@link WayofTime.bloodmagic.tile.TileImperfectRitualStone#performRitual(World, BlockPos, ImperfectRitual, EntityPlayer)}
|
||||
*
|
||||
* @param imperfectRitualStone - The {@link IImperfectRitualStone} that the ritual is bound to
|
||||
* @param player - The player activating the ritual
|
||||
*
|
||||
* @param imperfectRitualStone
|
||||
* - The {@link IImperfectRitualStone} that the ritual is bound
|
||||
* to
|
||||
* @param player
|
||||
* - The player activating the ritual
|
||||
* @return - Whether activation was successful
|
||||
*/
|
||||
public abstract boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player);
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public String toString()
|
||||
{
|
||||
return getName() + ":" + getRequiredBlock().toString() + "@" + getActivationCost();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,40 +10,50 @@ import net.minecraftforge.common.MinecraftForge;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BindableHelper {
|
||||
public class BindableHelper
|
||||
{
|
||||
|
||||
/**
|
||||
* Bind an item to a player. Handles checking if the player was an instanceof
|
||||
* {@link net.minecraftforge.common.util.FakePlayer} or other type of Fake Player.
|
||||
*
|
||||
* @param stack - The ItemStack to bind
|
||||
* @param player - The Player to bind the ItemStack to
|
||||
*
|
||||
* Bind an item to a player. Handles checking if the player was an
|
||||
* instanceof {@link net.minecraftforge.common.util.FakePlayer} or other
|
||||
* type of Fake Player.
|
||||
*
|
||||
* @param stack
|
||||
* - The ItemStack to bind
|
||||
* @param player
|
||||
* - The Player to bind the ItemStack to
|
||||
*
|
||||
* @return - Whether binding was successful
|
||||
*/
|
||||
public static boolean checkAndSetItemOwner(ItemStack stack, EntityPlayer player) {
|
||||
public static boolean checkAndSetItemOwner(ItemStack stack, EntityPlayer player)
|
||||
{
|
||||
return !PlayerHelper.isFakePlayer(player) && checkAndSetItemOwner(stack, PlayerHelper.getUUIDFromPlayer(player));
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind an item to a username.
|
||||
*
|
||||
* Requires the Item contained in the ItemStack to be an instanceof {@link IBindable}
|
||||
*
|
||||
*
|
||||
* Requires the Item contained in the ItemStack to be an instanceof
|
||||
* {@link IBindable}
|
||||
*
|
||||
* Fires {@link ItemBindEvent}.
|
||||
*
|
||||
* @param stack - The ItemStack to bind
|
||||
* @param uuid - The username to bind the ItemStack to
|
||||
*
|
||||
*
|
||||
* @param stack
|
||||
* - The ItemStack to bind
|
||||
* @param uuid
|
||||
* - The username to bind the ItemStack to
|
||||
*
|
||||
* @return - Whether the binding was successful
|
||||
*/
|
||||
public static boolean checkAndSetItemOwner(ItemStack stack, String uuid) {
|
||||
public static boolean checkAndSetItemOwner(ItemStack stack, String uuid)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
if (!(stack.getItem() instanceof IBindable))
|
||||
return false;
|
||||
|
||||
if (Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID))) {
|
||||
if (Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID)))
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new ItemBindEvent(PlayerHelper.getPlayerFromUUID(uuid), uuid, stack));
|
||||
((IBindable) stack.getItem()).onBind(PlayerHelper.getPlayerFromUUID(uuid), stack);
|
||||
stack.getTagCompound().setString(Constants.NBT.OWNER_UUID, uuid);
|
||||
|
@ -56,18 +66,22 @@ public class BindableHelper {
|
|||
/**
|
||||
* @see BindableHelper#checkAndSetItemOwner(ItemStack, String)
|
||||
*/
|
||||
public static boolean checkAndSetItemOwner(ItemStack stack, UUID uuid) {
|
||||
public static boolean checkAndSetItemOwner(ItemStack stack, UUID uuid)
|
||||
{
|
||||
return checkAndSetItemOwner(stack, uuid.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Owner of the item without checking if it is already bound.
|
||||
* Also bypasses {@link ItemBindEvent}.
|
||||
*
|
||||
* @param stack - The ItemStack to bind
|
||||
* @param ownerName - The username to bind the ItemStack to
|
||||
* Sets the Owner of the item without checking if it is already bound. Also
|
||||
* bypasses {@link ItemBindEvent}.
|
||||
*
|
||||
* @param stack
|
||||
* - The ItemStack to bind
|
||||
* @param ownerName
|
||||
* - The username to bind the ItemStack to
|
||||
*/
|
||||
public static void setItemOwner(ItemStack stack, String ownerName) {
|
||||
public static void setItemOwner(ItemStack stack, String ownerName)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
stack.getTagCompound().setString(Constants.NBT.OWNER_UUID, ownerName);
|
||||
|
@ -75,12 +89,14 @@ public class BindableHelper {
|
|||
|
||||
/**
|
||||
* Used to safely obtain the username of the ItemStack's owner
|
||||
*
|
||||
* @param stack - The ItemStack to check the owner of
|
||||
*
|
||||
*
|
||||
* @param stack
|
||||
* - The ItemStack to check the owner of
|
||||
*
|
||||
* @return - The username of the ItemStack's owner
|
||||
*/
|
||||
public static String getOwnerName(ItemStack stack) {
|
||||
public static String getOwnerName(ItemStack stack)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
return PlayerHelper.getUsernameFromStack(stack);
|
||||
|
@ -88,12 +104,14 @@ public class BindableHelper {
|
|||
|
||||
/**
|
||||
* Used to safely obtain the UUID of the ItemStack's owner
|
||||
*
|
||||
* @param stack - The ItemStack to check the owner of
|
||||
*
|
||||
*
|
||||
* @param stack
|
||||
* - The ItemStack to check the owner of
|
||||
*
|
||||
* @return - The UUID of the ItemStack's owner
|
||||
*/
|
||||
public static String getOwnerUUID(ItemStack stack) {
|
||||
public static String getOwnerUUID(ItemStack stack)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
return stack.getTagCompound().getString(Constants.NBT.OWNER_UUID);
|
||||
|
|
|
@ -4,18 +4,22 @@ import WayofTime.bloodmagic.api.Constants;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class IncenseHelper {
|
||||
public class IncenseHelper
|
||||
{
|
||||
|
||||
public static float getCurrentIncense(EntityPlayer player) {
|
||||
public static float getCurrentIncense(EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound data = player.getEntityData();
|
||||
if (data.hasKey(Constants.NBT.CURRENT_INCENSE)) {
|
||||
if (data.hasKey(Constants.NBT.CURRENT_INCENSE))
|
||||
{
|
||||
return data.getFloat(Constants.NBT.CURRENT_INCENSE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void setCurrentIncense(EntityPlayer player, float amount) {
|
||||
public static void setCurrentIncense(EntityPlayer player, float amount)
|
||||
{
|
||||
NBTTagCompound data = player.getEntityData();
|
||||
data.setFloat(Constants.NBT.CURRENT_INCENSE, amount);
|
||||
}
|
||||
|
|
|
@ -4,34 +4,41 @@ import WayofTime.bloodmagic.api.BloodMagicAPI;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class LogHelper {
|
||||
public class LogHelper
|
||||
{
|
||||
|
||||
private Logger logger;
|
||||
|
||||
public LogHelper(String logger) {
|
||||
public LogHelper(String logger)
|
||||
{
|
||||
this.logger = LogManager.getLogger(logger);
|
||||
}
|
||||
|
||||
public void info(String info, Object ... format) {
|
||||
public void info(String info, Object... format)
|
||||
{
|
||||
if (BloodMagicAPI.isLoggingEnabled())
|
||||
logger.info(info, format);
|
||||
}
|
||||
|
||||
public void error(String error, Object ... format) {
|
||||
public void error(String error, Object... format)
|
||||
{
|
||||
if (BloodMagicAPI.isLoggingEnabled())
|
||||
logger.info(error, format);
|
||||
}
|
||||
|
||||
public void debug(String debug, Object ... format) {
|
||||
public void debug(String debug, Object... format)
|
||||
{
|
||||
if (BloodMagicAPI.isLoggingEnabled())
|
||||
logger.info(debug, format);
|
||||
}
|
||||
|
||||
public void fatal(String fatal, Object ... format) {
|
||||
public void fatal(String fatal, Object... format)
|
||||
{
|
||||
logger.fatal(fatal, format);
|
||||
}
|
||||
|
||||
public Logger getLogger() {
|
||||
public Logger getLogger()
|
||||
{
|
||||
return logger;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,11 @@ package WayofTime.bloodmagic.api.util.helper;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class NBTHelper {
|
||||
public class NBTHelper
|
||||
{
|
||||
|
||||
public static ItemStack checkNBT(ItemStack stack) {
|
||||
public static ItemStack checkNBT(ItemStack stack)
|
||||
{
|
||||
if (stack.getTagCompound() == null)
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
|
|
|
@ -15,22 +15,27 @@ import net.minecraftforge.fml.common.eventhandler.Event;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
public class NetworkHelper {
|
||||
public class NetworkHelper
|
||||
{
|
||||
|
||||
// Get
|
||||
|
||||
/**
|
||||
* Gets the SoulNetwork for the player.
|
||||
*
|
||||
* @param name - The username of the SoulNetwork owner
|
||||
* @param world - The world
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* - The username of the SoulNetwork owner
|
||||
* @param world
|
||||
* - The world
|
||||
*
|
||||
* @return - The SoulNetwork for the given name.
|
||||
*/
|
||||
public static SoulNetwork getSoulNetwork(String name, World world) {
|
||||
public static SoulNetwork getSoulNetwork(String name, World world)
|
||||
{
|
||||
SoulNetwork network = (SoulNetwork) world.getMapStorage().loadData(SoulNetwork.class, name);
|
||||
|
||||
if (network == null) {
|
||||
if (network == null)
|
||||
{
|
||||
network = new SoulNetwork(name);
|
||||
world.getMapStorage().setData(name, network);
|
||||
}
|
||||
|
@ -41,42 +46,51 @@ public class NetworkHelper {
|
|||
/**
|
||||
* @see NetworkHelper#getSoulNetwork(String, World)
|
||||
*/
|
||||
public static SoulNetwork getSoulNetwork(UUID uuid, World world) {
|
||||
public static SoulNetwork getSoulNetwork(UUID uuid, World world)
|
||||
{
|
||||
return getSoulNetwork(PlayerHelper.getUsernameFromUUID(uuid), world);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see NetworkHelper#getSoulNetwork(String, World)
|
||||
*/
|
||||
public static SoulNetwork getSoulNetwork(EntityPlayer player, World world) {
|
||||
public static SoulNetwork getSoulNetwork(EntityPlayer player, World world)
|
||||
{
|
||||
return getSoulNetwork(PlayerHelper.getUUIDFromPlayer(player), world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current orb tier of the SoulNetwork.
|
||||
*
|
||||
* @param soulNetwork - SoulNetwork to get the tier of.
|
||||
*
|
||||
*
|
||||
* @param soulNetwork
|
||||
* - SoulNetwork to get the tier of.
|
||||
*
|
||||
* @return - The Orb tier of the given SoulNetwork
|
||||
*/
|
||||
public static int getCurrentMaxOrb(SoulNetwork soulNetwork) {
|
||||
public static int getCurrentMaxOrb(SoulNetwork soulNetwork)
|
||||
{
|
||||
return soulNetwork.getOrbTier();
|
||||
}
|
||||
|
||||
// Syphon
|
||||
|
||||
/**
|
||||
* Syphons from the player and damages them if there was not enough stored LP.
|
||||
*
|
||||
* Syphons from the player and damages them if there was not enough stored
|
||||
* LP.
|
||||
*
|
||||
* Handles null-checking the player for you.
|
||||
*
|
||||
* @param soulNetwork - SoulNetwork to syphon from
|
||||
* @param toSyphon - Amount of LP to syphon
|
||||
*
|
||||
*
|
||||
* @param soulNetwork
|
||||
* - SoulNetwork to syphon from
|
||||
* @param toSyphon
|
||||
* - Amount of LP to syphon
|
||||
*
|
||||
* @return - Whether the action should be performed.
|
||||
*/
|
||||
public static boolean syphonAndDamage(SoulNetwork soulNetwork, int toSyphon) {
|
||||
if (soulNetwork.getPlayer() == null) {
|
||||
public static boolean syphonAndDamage(SoulNetwork soulNetwork, int toSyphon)
|
||||
{
|
||||
if (soulNetwork.getPlayer() == null)
|
||||
{
|
||||
soulNetwork.syphon(toSyphon);
|
||||
return true;
|
||||
}
|
||||
|
@ -86,14 +100,18 @@ public class NetworkHelper {
|
|||
|
||||
/**
|
||||
* Syphons a player from within a container.
|
||||
*
|
||||
* @param stack - ItemStack in the Container.
|
||||
* @param world - The world the Container is in
|
||||
* @param toSyphon - Amount of LP to syphon
|
||||
*
|
||||
*
|
||||
* @param stack
|
||||
* - ItemStack in the Container.
|
||||
* @param world
|
||||
* - The world the Container is in
|
||||
* @param toSyphon
|
||||
* - Amount of LP to syphon
|
||||
*
|
||||
* @return - If the syphon was successful.
|
||||
*/
|
||||
public static boolean syphonFromContainer(ItemStack stack, World world, int toSyphon) {
|
||||
public static boolean syphonFromContainer(ItemStack stack, World world, int toSyphon)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
String ownerName = stack.getTagCompound().getString(Constants.NBT.OWNER_UUID);
|
||||
|
||||
|
@ -110,13 +128,16 @@ public class NetworkHelper {
|
|||
// Set
|
||||
|
||||
/**
|
||||
* Sets the orb tier of the SoulNetwork to the given orb. Will not set
|
||||
* if the given tier is lower than the current tier.
|
||||
*
|
||||
* @param soulNetwork - SoulNetwork to set the orb tier of
|
||||
* @param maxOrb - Tier of orb to set to
|
||||
* Sets the orb tier of the SoulNetwork to the given orb. Will not set if
|
||||
* the given tier is lower than the current tier.
|
||||
*
|
||||
* @param soulNetwork
|
||||
* - SoulNetwork to set the orb tier of
|
||||
* @param maxOrb
|
||||
* - Tier of orb to set to
|
||||
*/
|
||||
public static void setMaxOrb(SoulNetwork soulNetwork, int maxOrb) {
|
||||
public static void setMaxOrb(SoulNetwork soulNetwork, int maxOrb)
|
||||
{
|
||||
soulNetwork.setOrbTier(Math.max(maxOrb, soulNetwork.getOrbTier()));
|
||||
soulNetwork.markDirty();
|
||||
}
|
||||
|
@ -124,23 +145,29 @@ public class NetworkHelper {
|
|||
// TODO - Remove everything below. It is deprecated and should not be used.
|
||||
|
||||
/**
|
||||
* 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 stack Owned itemStack
|
||||
* @param player Player using the item
|
||||
*
|
||||
* @return True if the action should be executed and false if it should not. Always returns false if client-sided.
|
||||
* 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 stack
|
||||
* Owned itemStack
|
||||
* @param player
|
||||
* Player using the item
|
||||
*
|
||||
* @return True if the action should be executed and false if it should not.
|
||||
* Always returns false if client-sided.
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean syphonAndDamageFromNetwork(ItemStack stack, EntityPlayer player, int syphon) {
|
||||
public static boolean syphonAndDamageFromNetwork(ItemStack stack, EntityPlayer player, int syphon)
|
||||
{
|
||||
if (player.worldObj.isRemote)
|
||||
return false;
|
||||
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
String ownerName = stack.getTagCompound().getString(Constants.NBT.OWNER_UUID);
|
||||
|
||||
if (!Strings.isNullOrEmpty(ownerName)) {
|
||||
if (!Strings.isNullOrEmpty(ownerName))
|
||||
{
|
||||
SoulNetworkEvent.ItemDrainNetworkEvent event = new SoulNetworkEvent.ItemDrainNetworkEvent(player, ownerName, stack, syphon);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
|
@ -151,7 +178,8 @@ public class NetworkHelper {
|
|||
if (drainAmount == 0 || event.shouldDamage)
|
||||
hurtPlayer(player, event.syphon);
|
||||
|
||||
//The event has been told to prevent the action but allow all repercussions of using the item.
|
||||
// The event has been told to prevent the action but allow all
|
||||
// repercussions of using the item.
|
||||
return event.getResult() != Event.Result.DENY;
|
||||
}
|
||||
|
||||
|
@ -163,7 +191,8 @@ public class NetworkHelper {
|
|||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean syphonFromNetworkWhileInContainer(ItemStack stack, int syphon) {
|
||||
public static boolean syphonFromNetworkWhileInContainer(ItemStack stack, int syphon)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
String ownerName = stack.getTagCompound().getString(Constants.NBT.OWNER_UUID);
|
||||
|
||||
|
@ -179,7 +208,8 @@ public class NetworkHelper {
|
|||
}
|
||||
|
||||
@Deprecated
|
||||
public static int syphonFromNetwork(ItemStack stack, int syphon) {
|
||||
public static int syphonFromNetwork(ItemStack stack, int syphon)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
String ownerName = stack.getTagCompound().getString(Constants.NBT.OWNER_UUID);
|
||||
if (!Strings.isNullOrEmpty(ownerName))
|
||||
|
@ -189,19 +219,22 @@ public class NetworkHelper {
|
|||
}
|
||||
|
||||
@Deprecated
|
||||
public static int syphonFromNetwork(String ownerName, int syphon) {
|
||||
public static int syphonFromNetwork(String ownerName, int syphon)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
return 0;
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
SoulNetwork network = (SoulNetwork) world.loadItemData(SoulNetwork.class, ownerName);
|
||||
|
||||
if (network == null) {
|
||||
if (network == null)
|
||||
{
|
||||
network = new SoulNetwork(ownerName);
|
||||
world.setItemData(ownerName, network);
|
||||
}
|
||||
|
||||
if (network.getCurrentEssence() >= syphon) {
|
||||
if (network.getCurrentEssence() >= syphon)
|
||||
{
|
||||
network.setCurrentEssence(network.getCurrentEssence() - syphon);
|
||||
network.markDirty();
|
||||
return syphon;
|
||||
|
@ -214,11 +247,12 @@ public class NetworkHelper {
|
|||
|
||||
/**
|
||||
* A method to add to an owner's network up to a maximum value.
|
||||
*
|
||||
*
|
||||
* @return amount added to the network
|
||||
*/
|
||||
@Deprecated
|
||||
public static int addCurrentEssenceToMaximum(String ownerName, int addedEssence, int maximum) {
|
||||
public static int addCurrentEssenceToMaximum(String ownerName, int addedEssence, int maximum)
|
||||
{
|
||||
AddToNetworkEvent event = new AddToNetworkEvent(ownerName, addedEssence, maximum);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
|
@ -230,7 +264,8 @@ public class NetworkHelper {
|
|||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
SoulNetwork data = (SoulNetwork) world.loadItemData(SoulNetwork.class, event.ownerNetwork);
|
||||
|
||||
if (data == null) {
|
||||
if (data == null)
|
||||
{
|
||||
data = new SoulNetwork(event.ownerNetwork);
|
||||
world.setItemData(event.ownerNetwork, data);
|
||||
}
|
||||
|
@ -250,14 +285,16 @@ public class NetworkHelper {
|
|||
// Get
|
||||
|
||||
@Deprecated
|
||||
public static int getCurrentEssence(String ownerName) {
|
||||
public static int getCurrentEssence(String ownerName)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
return 0;
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
SoulNetwork network = (SoulNetwork) world.loadItemData(SoulNetwork.class, ownerName);
|
||||
|
||||
if (network == null) {
|
||||
if (network == null)
|
||||
{
|
||||
network = new SoulNetwork(ownerName);
|
||||
world.setItemData(ownerName, network);
|
||||
}
|
||||
|
@ -268,20 +305,27 @@ public class NetworkHelper {
|
|||
// Do damage
|
||||
|
||||
@Deprecated
|
||||
public static void hurtPlayer(EntityPlayer user, int energySyphoned) {
|
||||
if (energySyphoned < 100 && energySyphoned > 0) {
|
||||
if (!user.capabilities.isCreativeMode) {
|
||||
public static void hurtPlayer(EntityPlayer user, int energySyphoned)
|
||||
{
|
||||
if (energySyphoned < 100 && energySyphoned > 0)
|
||||
{
|
||||
if (!user.capabilities.isCreativeMode)
|
||||
{
|
||||
user.setHealth((user.getHealth() - 1));
|
||||
|
||||
if (user.getHealth() <= 0.0005f)
|
||||
user.onDeath(BloodMagicAPI.getDamageSource());
|
||||
}
|
||||
} else if (energySyphoned >= 100) {
|
||||
if (!user.capabilities.isCreativeMode) {
|
||||
for (int i = 0; i < ((energySyphoned + 99) / 100); i++) {
|
||||
} else if (energySyphoned >= 100)
|
||||
{
|
||||
if (!user.capabilities.isCreativeMode)
|
||||
{
|
||||
for (int i = 0; i < ((energySyphoned + 99) / 100); i++)
|
||||
{
|
||||
user.setHealth((user.getHealth() - 1));
|
||||
|
||||
if (user.getHealth() <= 0.0005f) {
|
||||
if (user.getHealth() <= 0.0005f)
|
||||
{
|
||||
user.onDeath(BloodMagicAPI.getDamageSource());
|
||||
break;
|
||||
}
|
||||
|
@ -291,8 +335,10 @@ public class NetworkHelper {
|
|||
}
|
||||
|
||||
@Deprecated
|
||||
public static void hurtPlayer(EntityPlayer user, float damage) {
|
||||
if (!user.capabilities.isCreativeMode) {
|
||||
public static void hurtPlayer(EntityPlayer user, float damage)
|
||||
{
|
||||
if (!user.capabilities.isCreativeMode)
|
||||
{
|
||||
user.attackEntityFrom(BloodMagicAPI.getDamageSource(), 0F);
|
||||
user.setHealth((user.getHealth() - damage));
|
||||
}
|
||||
|
|
|
@ -13,59 +13,71 @@ import net.minecraftforge.common.util.FakePlayer;
|
|||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class PlayerHelper {
|
||||
public class PlayerHelper
|
||||
{
|
||||
|
||||
private static final Pattern FAKE_PLAYER_PATTERN = Pattern.compile("^(?:\\[.*\\])|(?:ComputerCraft)$");
|
||||
|
||||
public static String getUsernameFromPlayer(EntityPlayer player) {
|
||||
public static String getUsernameFromPlayer(EntityPlayer player)
|
||||
{
|
||||
return UsernameCache.getLastKnownUsername(getUUIDFromPlayer(player));
|
||||
}
|
||||
|
||||
public static EntityPlayer getPlayerFromUsername(String username) {
|
||||
public static EntityPlayer getPlayerFromUsername(String username)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
return null;
|
||||
|
||||
return MinecraftServer.getServer().getConfigurationManager().getPlayerByUsername(username);
|
||||
}
|
||||
|
||||
public static EntityPlayer getPlayerFromUUID(String uuid) {
|
||||
public static EntityPlayer getPlayerFromUUID(String uuid)
|
||||
{
|
||||
return getPlayerFromUsername(getUsernameFromUUID(uuid));
|
||||
}
|
||||
|
||||
public static EntityPlayer getPlayerFromUUID(UUID uuid) {
|
||||
public static EntityPlayer getPlayerFromUUID(UUID uuid)
|
||||
{
|
||||
return getPlayerFromUsername(getUsernameFromUUID(uuid));
|
||||
}
|
||||
|
||||
public static UUID getUUIDFromPlayer(EntityPlayer player) {
|
||||
public static UUID getUUIDFromPlayer(EntityPlayer player)
|
||||
{
|
||||
return player.getGameProfile().getId();
|
||||
}
|
||||
|
||||
public static String getUsernameFromUUID(String uuid) {
|
||||
public static String getUsernameFromUUID(String uuid)
|
||||
{
|
||||
return UsernameCache.getLastKnownUsername(UUID.fromString(uuid));
|
||||
}
|
||||
|
||||
public static String getUsernameFromUUID(UUID uuid) {
|
||||
public static String getUsernameFromUUID(UUID uuid)
|
||||
{
|
||||
return UsernameCache.getLastKnownUsername(uuid);
|
||||
}
|
||||
|
||||
public static String getUsernameFromStack(ItemStack stack) {
|
||||
public static String getUsernameFromStack(ItemStack stack)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
return PlayerHelper.getUsernameFromUUID(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID));
|
||||
}
|
||||
|
||||
public static boolean isFakePlayer(EntityPlayer player) {
|
||||
public static boolean isFakePlayer(EntityPlayer player)
|
||||
{
|
||||
return player instanceof FakePlayer || FAKE_PLAYER_PATTERN.matcher(getUsernameFromPlayer(player)).matches();
|
||||
}
|
||||
|
||||
public static void causeNauseaToPlayer(ItemStack stack) {
|
||||
public static void causeNauseaToPlayer(ItemStack stack)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
if (!Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID)))
|
||||
causeNauseaToPlayer(stack.getTagCompound().getString(Constants.NBT.OWNER_UUID));
|
||||
}
|
||||
|
||||
public static void causeNauseaToPlayer(String ownerName) {
|
||||
public static void causeNauseaToPlayer(String ownerName)
|
||||
{
|
||||
EntityPlayer player = getPlayerFromUsername(ownerName);
|
||||
|
||||
if (player == null)
|
||||
|
|
|
@ -8,48 +8,59 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PlayerSacrificeHelper {
|
||||
public class PlayerSacrificeHelper
|
||||
{
|
||||
public static float scalingOfSacrifice = 0.001f;
|
||||
public static int soulFrayDuration = 400;
|
||||
public static Potion soulFrayId;
|
||||
|
||||
public static float getPlayerIncense(EntityPlayer player) {
|
||||
public static float getPlayerIncense(EntityPlayer player)
|
||||
{
|
||||
return IncenseHelper.getCurrentIncense(player);
|
||||
}
|
||||
|
||||
public static void setPlayerIncense(EntityPlayer player, float amount) {
|
||||
public static void setPlayerIncense(EntityPlayer player, float amount)
|
||||
{
|
||||
IncenseHelper.setCurrentIncense(player, amount);
|
||||
}
|
||||
|
||||
public static boolean incrementIncense(EntityPlayer player, float min, float max, float increment) {
|
||||
public static boolean incrementIncense(EntityPlayer player, float min, float max, float increment)
|
||||
{
|
||||
float amount = getPlayerIncense(player);
|
||||
if (amount < min || amount >= max) {
|
||||
if (amount < min || amount >= max)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
amount = amount + Math.min(increment, max - amount);
|
||||
setPlayerIncense(player, amount);
|
||||
|
||||
// System.out.println("Amount of incense: " + amount + ", Increment: " + increment);
|
||||
// System.out.println("Amount of incense: " + amount + ", Increment: " +
|
||||
// increment);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean sacrificePlayerHealth(EntityPlayer player) {
|
||||
if (player.isPotionActive(soulFrayId)) {
|
||||
public static boolean sacrificePlayerHealth(EntityPlayer player)
|
||||
{
|
||||
if (player.isPotionActive(soulFrayId))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
float amount = getPlayerIncense(player);
|
||||
|
||||
if (amount >= 0) {
|
||||
if (amount >= 0)
|
||||
{
|
||||
float health = player.getHealth();
|
||||
float maxHealth = player.getMaxHealth();
|
||||
|
||||
if (health > maxHealth / 10.0) {
|
||||
if (health > maxHealth / 10.0)
|
||||
{
|
||||
float sacrificedHealth = health - maxHealth / 10.0f;
|
||||
|
||||
if (findAndFillAltar(player.getEntityWorld(), player, (int) (sacrificedHealth * 100f * getModifier(amount)))) {
|
||||
if (findAndFillAltar(player.getEntityWorld(), player, (int) (sacrificedHealth * 100f * getModifier(amount))))
|
||||
{
|
||||
player.setHealth(maxHealth / 10.0f);
|
||||
setPlayerIncense(player, 0);
|
||||
player.addPotionEffect(new PotionEffect(soulFrayId.id, soulFrayDuration));
|
||||
|
@ -62,17 +73,20 @@ public class PlayerSacrificeHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static float getModifier(float amount) {
|
||||
public static float getModifier(float amount)
|
||||
{
|
||||
return 1 + amount * scalingOfSacrifice;
|
||||
}
|
||||
|
||||
public static boolean findAndFillAltar(World world, EntityPlayer player, int amount) {
|
||||
public static boolean findAndFillAltar(World world, EntityPlayer player, int amount)
|
||||
{
|
||||
int posX = (int) Math.round(player.posX - 0.5f);
|
||||
int posY = (int) player.posY;
|
||||
int posZ = (int) Math.round(player.posZ - 0.5f);
|
||||
IBloodAltar altarEntity = getAltar(world, new BlockPos(posX, posY, posZ));
|
||||
|
||||
if (altarEntity == null) {
|
||||
if (altarEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -82,15 +96,20 @@ public class PlayerSacrificeHelper {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static IBloodAltar getAltar(World world, BlockPos blockPos) {
|
||||
public static IBloodAltar getAltar(World world, BlockPos blockPos)
|
||||
{
|
||||
TileEntity tileEntity;
|
||||
|
||||
for (int i = -2; i <= 2; i++) {
|
||||
for (int j = -2; j <= 2; j++) {
|
||||
for (int k = -2; k <= 1; k++) {
|
||||
for (int i = -2; i <= 2; i++)
|
||||
{
|
||||
for (int j = -2; j <= 2; j++)
|
||||
{
|
||||
for (int k = -2; k <= 1; k++)
|
||||
{
|
||||
tileEntity = world.getTileEntity(new BlockPos(i + blockPos.getX(), k + blockPos.getY(), j + blockPos.getZ()));
|
||||
|
||||
if (tileEntity instanceof IBloodAltar) {
|
||||
if (tileEntity instanceof IBloodAltar)
|
||||
{
|
||||
return (IBloodAltar) tileEntity;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,20 +19,24 @@ import WayofTime.bloodmagic.api.ritual.Ritual;
|
|||
import WayofTime.bloodmagic.api.ritual.RitualComponent;
|
||||
import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual;
|
||||
|
||||
public class RitualHelper {
|
||||
public class RitualHelper
|
||||
{
|
||||
|
||||
public static boolean canCrystalActivate(Ritual ritual, int crystalLevel) {
|
||||
public static boolean canCrystalActivate(Ritual ritual, int crystalLevel)
|
||||
{
|
||||
return ritual.getCrystalLevel() <= crystalLevel && RitualRegistry.ritualEnabled(ritual);
|
||||
}
|
||||
|
||||
public static String getNextRitualKey(String currentKey) {
|
||||
public static String getNextRitualKey(String currentKey)
|
||||
{
|
||||
int currentIndex = RitualRegistry.getIds().indexOf(currentKey);
|
||||
int nextIndex = RitualRegistry.getRituals().listIterator(currentIndex).nextIndex();
|
||||
|
||||
return RitualRegistry.getIds().get(nextIndex);
|
||||
}
|
||||
|
||||
public static String getPrevRitualKey(String currentKey) {
|
||||
public static String getPrevRitualKey(String currentKey)
|
||||
{
|
||||
int currentIndex = RitualRegistry.getIds().indexOf(currentKey);
|
||||
int previousIndex = RitualRegistry.getIds().listIterator(currentIndex).previousIndex();
|
||||
|
||||
|
@ -40,87 +44,106 @@ public class RitualHelper {
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks the RitualRegistry to see if the configuration of the ritual stones in the world is valid
|
||||
* for the given EnumFacing.
|
||||
*
|
||||
* Checks the RitualRegistry to see if the configuration of the ritual
|
||||
* stones in the world is valid for the given EnumFacing.
|
||||
*
|
||||
* @return The ID of the valid ritual
|
||||
*/
|
||||
public static String getValidRitual(World world, BlockPos pos) {
|
||||
for(String key : RitualRegistry.getIds()) {
|
||||
for(EnumFacing direction : EnumFacing.HORIZONTALS) {
|
||||
boolean test = checkValidRitual(world, pos, key, direction);
|
||||
if(test) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
public static String getValidRitual(World world, BlockPos pos)
|
||||
{
|
||||
for (String key : RitualRegistry.getIds())
|
||||
{
|
||||
for (EnumFacing direction : EnumFacing.HORIZONTALS)
|
||||
{
|
||||
boolean test = checkValidRitual(world, pos, key, direction);
|
||||
if (test)
|
||||
{
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static EnumFacing getDirectionOfRitual(World world, BlockPos pos, String key) {
|
||||
for(EnumFacing direction : EnumFacing.HORIZONTALS) {
|
||||
boolean test = checkValidRitual(world, pos, key, direction);
|
||||
if(test) {
|
||||
return direction;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
public static EnumFacing getDirectionOfRitual(World world, BlockPos pos, String key)
|
||||
{
|
||||
for (EnumFacing direction : EnumFacing.HORIZONTALS)
|
||||
{
|
||||
boolean test = checkValidRitual(world, pos, key, direction);
|
||||
if (test)
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean checkValidRitual(World world, BlockPos pos, String ritualId, EnumFacing direction) {
|
||||
Ritual ritual = RitualRegistry.getRitualForId(ritualId);
|
||||
if(ritual == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static boolean checkValidRitual(World world, BlockPos pos, String ritualId, EnumFacing direction)
|
||||
{
|
||||
Ritual ritual = RitualRegistry.getRitualForId(ritualId);
|
||||
if (ritual == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ArrayList<RitualComponent> components = ritual.getComponents();
|
||||
|
||||
|
||||
if (components == null)
|
||||
return false;
|
||||
|
||||
for (RitualComponent component : components) {
|
||||
BlockPos newPos = pos.add(component.getOffset(direction));
|
||||
|
||||
for (RitualComponent component : components)
|
||||
{
|
||||
BlockPos newPos = pos.add(component.getOffset(direction));
|
||||
IBlockState worldState = world.getBlockState(newPos);
|
||||
Block block = worldState.getBlock();
|
||||
if (block instanceof IRitualStone) {
|
||||
if(!((IRitualStone)block).isRuneType(world, newPos, component.getRuneType())) {
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
return false;
|
||||
if (block instanceof IRitualStone)
|
||||
{
|
||||
if (!((IRitualStone) block).isRuneType(world, newPos, component.getRuneType()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void checkImperfectRituals(Configuration config, String packageName, String category) {
|
||||
public static void checkImperfectRituals(Configuration config, String packageName, String category)
|
||||
{
|
||||
checkRituals(config, packageName, category, ImperfectRitual.class, ImperfectRitualRegistry.enabledRituals);
|
||||
}
|
||||
|
||||
public static void checkRituals(Configuration config, String packageName, String category) {
|
||||
public static void checkRituals(Configuration config, String packageName, String category)
|
||||
{
|
||||
checkRituals(config, packageName, category, Ritual.class, RitualRegistry.enabledRituals);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds your Ritual to the {@link RitualRegistry#enabledRituals} Map.
|
||||
* This is used to determine whether your effect is enabled or not.
|
||||
*
|
||||
* The config option will be created as {@code B:ClassName=true} with a comment of
|
||||
* {@code Enables the ClassName ritual}.
|
||||
*
|
||||
* Adds your Ritual to the {@link RitualRegistry#enabledRituals} Map. This
|
||||
* is used to determine whether your effect is enabled or not.
|
||||
*
|
||||
* The config option will be created as {@code B:ClassName=true} with a
|
||||
* comment of {@code Enables the ClassName ritual}.
|
||||
*
|
||||
* Use {@link #}
|
||||
*
|
||||
*
|
||||
* Should be safe to modify at any point.
|
||||
*
|
||||
* @param config - Your mod's Forge {@link Configuration} object.
|
||||
* @param packageName - The package your Rituals are located in.
|
||||
* @param category - The config category to write to.
|
||||
*
|
||||
* @param config
|
||||
* - Your mod's Forge {@link Configuration} object.
|
||||
* @param packageName
|
||||
* - The package your Rituals are located in.
|
||||
* @param category
|
||||
* - The config category to write to.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void checkRituals(Configuration config, String packageName, String category, Class ritualClass, Map enabledMap) {
|
||||
private static void checkRituals(Configuration config, String packageName, String category, Class ritualClass, Map enabledMap)
|
||||
{
|
||||
String name = packageName;
|
||||
if (!name.startsWith("/"))
|
||||
name = "/" + name;
|
||||
|
@ -129,24 +152,31 @@ public class RitualHelper {
|
|||
URL url = BloodMagic.class.getResource(name);
|
||||
File directory = new File(url.getFile());
|
||||
|
||||
if (directory.exists()) {
|
||||
if (directory.exists())
|
||||
{
|
||||
String[] files = directory.list();
|
||||
|
||||
for (String file : files) {
|
||||
if (file.endsWith(".class")) {
|
||||
for (String file : files)
|
||||
{
|
||||
if (file.endsWith(".class"))
|
||||
{
|
||||
String className = file.substring(0, file.length() - 6);
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
Object o = Class.forName(packageName + "." + className).newInstance();
|
||||
|
||||
if (ritualClass.isInstance(o))
|
||||
enabledMap.put(ritualClass.cast(o), config.get(category, className, true).getBoolean());
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
} catch (ClassNotFoundException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
} catch (InstantiationException e) {
|
||||
} catch (InstantiationException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (IllegalAccessException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue