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;
|
2015-12-03 00:02:18 +00:00
|
|
|
import WayofTime.bloodmagic.util.Utils;
|
2015-10-30 03:22:14 +00:00
|
|
|
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 03:18:53 +00:00
|
|
|
public class BloodAltar {
|
|
|
|
|
2015-11-28 01:15:19 +00:00
|
|
|
static {
|
|
|
|
EnumAltarTier.ONE.buildComponents();
|
|
|
|
EnumAltarTier.TWO.buildComponents();
|
|
|
|
EnumAltarTier.THREE.buildComponents();
|
|
|
|
EnumAltarTier.FOUR.buildComponents();
|
|
|
|
EnumAltarTier.FIVE.buildComponents();
|
|
|
|
EnumAltarTier.SIX.buildComponents();
|
|
|
|
}
|
|
|
|
|
2015-11-03 03:18:53 +00:00
|
|
|
public static EnumAltarTier getAltarTier(World world, BlockPos pos) {
|
2015-11-28 01:15:19 +00:00
|
|
|
for (int i = EnumAltarTier.MAXTIERS - 1; i >= 1; i--) {
|
2015-11-03 03:18:53 +00:00
|
|
|
if (checkAltarIsValid(world, pos, i)) {
|
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 03:18:53 +00:00
|
|
|
public static boolean checkAltarIsValid(World world, BlockPos worldPos, int altarTier) {
|
2015-11-28 01:15:19 +00:00
|
|
|
|
2015-11-03 03:18:53 +00:00
|
|
|
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-12-03 00:02:18 +00:00
|
|
|
if (altarComponent.getComponent() != EnumAltarComponent.NOTAIR) {
|
|
|
|
if (worldBlock.getBlock() instanceof IAltarComponent) {
|
|
|
|
EnumAltarComponent component = ((IAltarComponent) worldBlock.getBlock()).getType(worldBlock.getMeta());
|
|
|
|
if (component != altarComponent.getComponent())
|
2015-10-30 03:22:14 +00:00
|
|
|
return false;
|
2015-12-03 00:02:18 +00:00
|
|
|
} else if (worldBlock.getBlock() != Utils.getBlockForComponent(altarComponent.getComponent())) {
|
|
|
|
return false;
|
2015-11-03 02:30:28 +00:00
|
|
|
}
|
2015-12-03 00:02:18 +00:00
|
|
|
} else {
|
|
|
|
if (world.isAirBlock(componentPos))
|
|
|
|
return false;
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-28 01:15:19 +00:00
|
|
|
return true;
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|
|
|
|
|
2015-11-08 02:37:12 +00:00
|
|
|
public static AltarUpgrade getUpgrades(World world, BlockPos pos, EnumAltarTier altarTier) {
|
|
|
|
if (world.isRemote) {
|
2015-11-03 02:30:28 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
AltarUpgrade upgrades = new AltarUpgrade();
|
2015-11-03 15:34:11 +00:00
|
|
|
List<AltarComponent> list = altarTier.getAltarComponents();
|
2015-11-03 02:30:28 +00:00
|
|
|
|
2015-11-03 03:18:53 +00:00
|
|
|
for (AltarComponent altarComponent : list) {
|
2015-11-03 02:30:28 +00:00
|
|
|
BlockPos componentPos = pos.add(altarComponent.getOffset());
|
|
|
|
|
2015-11-03 03:18:53 +00:00
|
|
|
if (altarComponent.isUpgradeSlot()) {
|
2015-11-03 02:30:28 +00:00
|
|
|
BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos)));
|
|
|
|
|
2015-11-03 03:18:53 +00:00
|
|
|
if (worldBlock.getBlock() instanceof BlockBloodRune) {
|
|
|
|
switch (((BlockBloodRune) worldBlock.getBlock()).getRuneEffect(worldBlock.getMeta())) {
|
2015-11-03 02:30:28 +00:00
|
|
|
case 1:
|
|
|
|
upgrades.addSpeed();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
upgrades.addEfficiency();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
upgrades.addSacrifice();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
upgrades.addSelfSacrifice();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
2015-11-03 03:18:53 +00:00
|
|
|
upgrades.addDisplacement();
|
2015-11-03 02:30:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
2015-11-03 03:18:53 +00:00
|
|
|
upgrades.addCapacity();
|
2015-11-03 02:30:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 7:
|
2015-11-03 03:18:53 +00:00
|
|
|
upgrades.addBetterCapacity();
|
2015-11-03 02:30:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
2015-11-03 03:18:53 +00:00
|
|
|
upgrades.addOrbCapacity();
|
2015-11-03 02:30:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 9:
|
|
|
|
upgrades.addAcceleration();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-10-30 03:22:14 +00:00
|
|
|
|
2015-11-03 02:30:28 +00:00
|
|
|
return upgrades;
|
|
|
|
}
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|