Added an initial (read: rough) method to divine where a blood rune is missing for the next tier of altar

This commit is contained in:
WayofTime 2016-06-02 19:09:02 -04:00
parent 686d79570f
commit cf72036ff9
5 changed files with 125 additions and 23 deletions

View file

@ -1,9 +1,32 @@
package WayofTime.bloodmagic.altar;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import WayofTime.bloodmagic.api.BlockStack;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.altar.*;
import WayofTime.bloodmagic.api.altar.AltarComponent;
import WayofTime.bloodmagic.api.altar.AltarUpgrade;
import WayofTime.bloodmagic.api.altar.EnumAltarComponent;
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
import WayofTime.bloodmagic.api.altar.IAltarComponent;
import WayofTime.bloodmagic.api.event.AltarCraftedEvent;
import WayofTime.bloodmagic.api.orb.IBloodOrb;
import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry;
@ -13,20 +36,9 @@ import WayofTime.bloodmagic.block.BlockBloodRune;
import WayofTime.bloodmagic.block.BlockLifeEssence;
import WayofTime.bloodmagic.tile.TileAltar;
import WayofTime.bloodmagic.util.Utils;
import com.google.common.base.Enums;
import com.google.common.base.Strings;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.*;
import java.util.List;
public class BloodAltar implements IFluidHandler
{
@ -99,10 +111,8 @@ public class BloodAltar implements IFluidHandler
public static boolean checkAltarIsValid(World world, BlockPos worldPos, int altarTier)
{
for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents())
{
BlockPos componentPos = worldPos.add(altarComponent.getOffset());
BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos)));
@ -127,6 +137,52 @@ public class BloodAltar implements IFluidHandler
return true;
}
public static PosAndComponent getAltarMissingBlock(World world, BlockPos worldPos, int altarTier)
{
if (altarTier >= EnumAltarTier.MAXTIERS)
{
return null;
}
for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents())
{
BlockPos componentPos = worldPos.add(altarComponent.getOffset());
BlockStack worldBlock = new BlockStack(world.getBlockState(componentPos).getBlock(), world.getBlockState(componentPos).getBlock().getMetaFromState(world.getBlockState(componentPos)));
if (altarComponent.getComponent() != EnumAltarComponent.NOTAIR)
{
if (worldBlock.getBlock() instanceof IAltarComponent)
{
EnumAltarComponent component = ((IAltarComponent) worldBlock.getBlock()).getType(worldBlock.getMeta());
if (component != altarComponent.getComponent())
{
return new PosAndComponent(componentPos, altarComponent.getComponent());
}
} else if (worldBlock.getBlock() != Utils.getBlockForComponent(altarComponent.getComponent()))
{
return new PosAndComponent(componentPos, altarComponent.getComponent());
}
} else
{
if (world.isAirBlock(componentPos))
{
return new PosAndComponent(componentPos, altarComponent.getComponent());
}
}
}
return null;
}
@AllArgsConstructor
@Getter
@Setter
public static class PosAndComponent
{
public final BlockPos pos;
public final EnumAltarComponent component;
}
public static AltarUpgrade getUpgrades(World world, BlockPos pos, EnumAltarTier altarTier)
{
if (world.isRemote)