Grew a Pair

This commit is contained in:
WayofTime 2016-06-02 19:13:50 -04:00
parent cf72036ff9
commit e406a4fa6f
2 changed files with 14 additions and 19 deletions
src/main/java/WayofTime/bloodmagic

View file

@ -2,9 +2,6 @@ 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;
@ -19,6 +16,10 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import WayofTime.bloodmagic.api.BlockStack;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.Constants;
@ -137,7 +138,7 @@ public class BloodAltar implements IFluidHandler
return true;
}
public static PosAndComponent getAltarMissingBlock(World world, BlockPos worldPos, int altarTier)
public static Pair<BlockPos, EnumAltarComponent> getAltarMissingBlock(World world, BlockPos worldPos, int altarTier)
{
if (altarTier >= EnumAltarTier.MAXTIERS)
{
@ -156,17 +157,17 @@ public class BloodAltar implements IFluidHandler
EnumAltarComponent component = ((IAltarComponent) worldBlock.getBlock()).getType(worldBlock.getMeta());
if (component != altarComponent.getComponent())
{
return new PosAndComponent(componentPos, altarComponent.getComponent());
return new ImmutablePair<BlockPos, EnumAltarComponent>(componentPos, altarComponent.getComponent());
}
} else if (worldBlock.getBlock() != Utils.getBlockForComponent(altarComponent.getComponent()))
{
return new PosAndComponent(componentPos, altarComponent.getComponent());
return new ImmutablePair<BlockPos, EnumAltarComponent>(componentPos, altarComponent.getComponent());
}
} else
{
if (world.isAirBlock(componentPos))
{
return new PosAndComponent(componentPos, altarComponent.getComponent());
return new ImmutablePair<BlockPos, EnumAltarComponent>(componentPos, altarComponent.getComponent());
}
}
}
@ -174,15 +175,6 @@ public class BloodAltar implements IFluidHandler
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)

View file

@ -11,10 +11,13 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import org.apache.commons.lang3.tuple.Pair;
import WayofTime.bloodmagic.altar.BloodAltar;
import WayofTime.bloodmagic.api.altar.EnumAltarComponent;
import WayofTime.bloodmagic.api.altar.IBloodAltar;
import WayofTime.bloodmagic.api.iface.IAltarReader;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
@ -60,10 +63,10 @@ public class ItemSigilDivination extends ItemSigilBase implements IAltarReader
if (player.isSneaking())
{
BloodAltar.PosAndComponent missingBlock = BloodAltar.getAltarMissingBlock(world, position.getBlockPos(), tier);
Pair<BlockPos, EnumAltarComponent> missingBlock = BloodAltar.getAltarMissingBlock(world, position.getBlockPos(), tier);
if (missingBlock != null)
{
ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.BloodMagic.altar.nextTier", new TextComponentTranslation(missingBlock.getComponent().getKey()), prettifyBlockPosString(missingBlock.getPos())));
ChatUtil.sendNoSpam(player, new TextComponentTranslation("chat.BloodMagic.altar.nextTier", new TextComponentTranslation(missingBlock.getRight().getKey()), prettifyBlockPosString(missingBlock.getLeft())));
}
} else