2015-11-02 20:39:44 +00:00
|
|
|
package WayofTime.bloodmagic.altar;
|
2015-10-30 03:22:14 +00:00
|
|
|
|
2015-11-02 20:39:44 +00:00
|
|
|
import WayofTime.bloodmagic.api.BlockStack;
|
2015-11-03 02:30:28 +00:00
|
|
|
import WayofTime.bloodmagic.api.altar.*;
|
|
|
|
import WayofTime.bloodmagic.block.BlockBloodRune;
|
|
|
|
import WayofTime.bloodmagic.registry.ModBlocks;
|
2015-10-30 03:22:14 +00:00
|
|
|
import net.minecraft.block.BlockBeacon;
|
|
|
|
import net.minecraft.block.BlockGlowstone;
|
|
|
|
import net.minecraft.init.Blocks;
|
|
|
|
import net.minecraft.util.BlockPos;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2015-11-03 02:30:28 +00:00
|
|
|
import java.util.List;
|
2015-10-30 03:22:14 +00:00
|
|
|
|
2015-11-03 02:30:28 +00:00
|
|
|
public class BloodAltar
|
|
|
|
{
|
|
|
|
|
|
|
|
public static EnumAltarTier getAltarTier(World world, BlockPos pos)
|
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
for (int i = EnumAltarTier.MAXTIERS; i >= 2; i--)
|
2015-11-03 02:30:28 +00:00
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
if (checkAltarIsValid(world, pos, i))
|
2015-11-03 02:30:28 +00:00
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
return EnumAltarTier.values()[i];
|
2015-11-03 02:30:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2015-10-30 03:22:14 +00:00
|
|
|
|
|
|
|
return EnumAltarTier.ONE;
|
|
|
|
}
|
|
|
|
|
2015-11-03 02:30:28 +00:00
|
|
|
public static boolean checkAltarIsValid(World world, BlockPos worldPos, int altarTier)
|
|
|
|
{
|
|
|
|
for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents())
|
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
|
|
|
|
BlockPos componentPos = worldPos.add(altarComponent.getOffset());
|
|
|
|
BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos)));
|
|
|
|
|
2015-11-03 02:30:28 +00:00
|
|
|
if (altarComponent.isBloodRune())
|
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
if (!checkRune(altarComponent, worldBlock))
|
2015-11-03 02:30:28 +00:00
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
return false;
|
2015-11-03 02:30:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
if (((altarComponent.getBlockStack().getBlock() != worldBlock.getBlock()) || (altarComponent.getBlockStack().getMeta() != worldBlock.getMeta())) && (altarComponent.getBlockStack().getBlock() == Blocks.air && !world.isAirBlock(componentPos)))
|
2015-11-03 02:30:28 +00:00
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
if (!checkSpecials(altarComponent, worldBlock))
|
2015-11-03 02:30:28 +00:00
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
return false;
|
2015-11-03 02:30:28 +00:00
|
|
|
}
|
|
|
|
}
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-11-03 02:30:28 +00:00
|
|
|
public static AltarUpgrade getUpgrades(World world, BlockPos pos, int altarTier)
|
|
|
|
{
|
|
|
|
if (world.isRemote)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
AltarUpgrade upgrades = new AltarUpgrade();
|
|
|
|
List<AltarComponent> list = EnumAltarTier.values()[altarTier].getAltarComponents();
|
|
|
|
|
|
|
|
for (AltarComponent altarComponent : list)
|
|
|
|
{
|
|
|
|
BlockPos componentPos = pos.add(altarComponent.getOffset());
|
|
|
|
|
|
|
|
if (altarComponent.isUpgradeSlot())
|
|
|
|
{
|
|
|
|
BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos)));
|
|
|
|
|
|
|
|
if (worldBlock.getBlock() instanceof BlockBloodRune)
|
|
|
|
{
|
|
|
|
switch (((BlockBloodRune) worldBlock.getBlock()).getRuneEffect(worldBlock.getMeta()))
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
upgrades.addSpeed();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
upgrades.addEfficiency();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
upgrades.addSacrifice();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
upgrades.addSelfSacrifice();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
upgrades.addCapacity();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
upgrades.addDisplacement();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
upgrades.addOrbCapacity();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
upgrades.addBetterCapacity();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 9:
|
|
|
|
upgrades.addAcceleration();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-10-30 03:22:14 +00:00
|
|
|
|
2015-11-03 02:30:28 +00:00
|
|
|
return upgrades;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static boolean checkRune(AltarComponent altarComponent, BlockStack blockStack)
|
|
|
|
{
|
|
|
|
if (altarComponent.getBlockStack().getBlock() == ModBlocks.blood_rune)
|
|
|
|
{
|
|
|
|
if (blockStack.getBlock() instanceof BlockBloodRune || (blockStack.getBlock() instanceof IAltarComponent && (((IAltarComponent) blockStack.getBlock()).getType(blockStack.getMeta()) == EnumAltarComponent.BLOODRUNE)))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2015-10-30 03:22:14 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-11-03 02:30:28 +00:00
|
|
|
private static boolean checkSpecials(AltarComponent altarComponent, BlockStack blockStack)
|
|
|
|
{
|
|
|
|
if (altarComponent.getBlockStack().getBlock() == ModBlocks.bloodStone)
|
2015-10-30 03:22:14 +00:00
|
|
|
// if (blockStack.getBlock() instanceof BlockBloodStone || (blockStack.getBlock() instanceof IAltarComponent && (((IAltarComponent) blockStack.getBlock()).getType(blockStack.getMeta()) == EnumAltarComponent.BLOODSTONE)))
|
2015-11-03 02:30:28 +00:00
|
|
|
return true;
|
2015-10-30 03:22:14 +00:00
|
|
|
|
2015-11-03 02:30:28 +00:00
|
|
|
if (altarComponent.getBlockStack().getBlock() == ModBlocks.crystal)
|
2015-10-30 03:22:14 +00:00
|
|
|
// if (blockStack.getBlock() instanceof BlockCrystal || (blockStack.getBlock() instanceof IAltarComponent && (((IAltarComponent) blockStack.getBlock()).getType(blockStack.getMeta()) == EnumAltarComponent.CRYSTAL)))
|
2015-11-03 02:30:28 +00:00
|
|
|
return true;
|
2015-10-30 03:22:14 +00:00
|
|
|
|
|
|
|
if (altarComponent.getBlockStack().getBlock() == Blocks.glowstone)
|
|
|
|
if (blockStack.getBlock() instanceof BlockGlowstone || (blockStack.getBlock() instanceof IAltarComponent && (((IAltarComponent) blockStack.getBlock()).getType(blockStack.getMeta()) == EnumAltarComponent.GLOWSTONE)))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (altarComponent.getBlockStack().getBlock() == Blocks.beacon)
|
|
|
|
if (blockStack.getBlock() instanceof BlockBeacon || (blockStack.getBlock() instanceof IAltarComponent && (((IAltarComponent) blockStack.getBlock()).getType(blockStack.getMeta()) == EnumAltarComponent.BEACON)))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|