2015-12-27 19:38:12 -05:00
|
|
|
package WayofTime.bloodmagic.item.sigil;
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.inventory.IInventory;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.ChatComponentText;
|
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
|
|
|
import net.minecraft.world.World;
|
2015-12-29 08:44:34 -05:00
|
|
|
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
|
|
|
import WayofTime.bloodmagic.api.iface.IAltarReader;
|
|
|
|
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
|
|
|
|
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
|
|
|
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
|
|
|
import WayofTime.bloodmagic.util.ChatUtil;
|
|
|
|
import WayofTime.bloodmagic.util.helper.TextHelper;
|
2015-12-27 19:38:12 -05:00
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
public class ItemSigilSeer extends ItemSigilBase implements IAltarReader
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
public ItemSigilSeer()
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
super("seer");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-12-30 15:34:40 -05:00
|
|
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
|
|
|
|
if (PlayerHelper.isFakePlayer(player))
|
|
|
|
return stack;
|
|
|
|
|
|
|
|
super.onItemRightClick(stack, world, player);
|
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
if (!world.isRemote)
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
MovingObjectPosition position = getMovingObjectPositionFromPlayer(world, player, false);
|
2015-12-28 20:13:11 -08:00
|
|
|
int currentEssence = NetworkHelper.getSoulNetwork(BindableHelper.getOwnerUUID(stack), world).getCurrentEssence();
|
2015-12-27 19:38:12 -05:00
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
if (position == null)
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
ChatUtil.sendNoSpam(player, new ChatComponentText(TextHelper.localize(tooltipBase + "currentEssence", currentEssence)));
|
|
|
|
return stack;
|
2015-12-30 15:34:40 -05:00
|
|
|
} else
|
|
|
|
{
|
|
|
|
if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
|
|
|
|
TileEntity tile = world.getTileEntity(position.getBlockPos());
|
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
if (tile != null && tile instanceof IBloodAltar)
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
IBloodAltar altar = (IBloodAltar) tile;
|
|
|
|
int tier = altar.getTier().ordinal() + 1;
|
|
|
|
currentEssence = altar.getCurrentBlood();
|
|
|
|
int capacity = altar.getCapacity();
|
|
|
|
altar.checkTier();
|
2015-12-30 15:34:40 -05:00
|
|
|
if (tile instanceof IInventory)
|
|
|
|
{
|
|
|
|
if (((IInventory) tile).getStackInSlot(0) != null)
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
int progress = altar.getProgress();
|
|
|
|
int totalLiquidRequired = altar.getLiquidRequired() * ((IInventory) tile).getStackInSlot(0).stackSize;
|
|
|
|
int consumptionRate = (int) (altar.getConsumptionRate() * (altar.getConsumptionMultiplier() + 1));
|
|
|
|
ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentAltarProgress", progress, totalLiquidRequired), TextHelper.localize(tooltipBase + "currentAltarConsumptionRate", consumptionRate), TextHelper.localize(tooltipBase + "currentAltarTier", tier), TextHelper.localize(tooltipBase + "currentEssence", currentEssence), TextHelper.localize(tooltipBase + "currentAltarCapacity", capacity));
|
2015-12-30 15:34:40 -05:00
|
|
|
} else
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentAltarTier", tier), TextHelper.localize(tooltipBase + "currentEssence", currentEssence), TextHelper.localize(tooltipBase + "currentAltarCapacity", capacity));
|
|
|
|
}
|
|
|
|
}
|
2015-12-30 15:34:40 -05:00
|
|
|
} else
|
|
|
|
{
|
2015-12-27 19:38:12 -05:00
|
|
|
ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentEssence", currentEssence));
|
|
|
|
}
|
|
|
|
|
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
}
|