2015-11-02 20:39:44 +00:00
|
|
|
package WayofTime.bloodmagic.item.sigil;
|
2015-10-30 05:05:00 +00:00
|
|
|
|
2015-12-30 16:34:04 +00:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
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;
|
2016-01-30 13:44:49 +00:00
|
|
|
import WayofTime.bloodmagic.api.Constants;
|
2015-11-02 20:39:44 +00:00
|
|
|
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
2015-11-03 15:34:11 +00:00
|
|
|
import WayofTime.bloodmagic.api.iface.IAltarReader;
|
2015-11-02 20:39:44 +00:00
|
|
|
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
|
|
|
|
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
2016-01-30 13:44:49 +00:00
|
|
|
import WayofTime.bloodmagic.tile.TileIncenseAltar;
|
2015-11-02 20:39:44 +00:00
|
|
|
import WayofTime.bloodmagic.util.ChatUtil;
|
|
|
|
import WayofTime.bloodmagic.util.helper.TextHelper;
|
2015-10-30 05:05:00 +00:00
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
public class ItemSigilDivination extends ItemSigilBase implements IAltarReader
|
|
|
|
{
|
|
|
|
public ItemSigilDivination()
|
|
|
|
{
|
2015-10-30 05:05:00 +00:00
|
|
|
super("divination");
|
2016-01-19 06:34:12 +00:00
|
|
|
setRegistryName(Constants.BloodMagicItem.SIGIL_DIVINATION.getRegName());
|
2015-10-30 05:05:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-12-30 20:34:40 +00:00
|
|
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
|
|
|
{
|
2015-10-30 05:05:00 +00:00
|
|
|
super.onItemRightClick(stack, world, player);
|
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
if (!world.isRemote)
|
|
|
|
{
|
2015-10-30 05:05:00 +00:00
|
|
|
MovingObjectPosition position = getMovingObjectPositionFromPlayer(world, player, false);
|
2016-02-04 08:25:37 +00:00
|
|
|
int currentEssence = NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).getCurrentEssence();
|
2015-10-30 05:05:00 +00:00
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
if (position == null)
|
|
|
|
{
|
2015-10-30 23:54:59 +00:00
|
|
|
ChatUtil.sendNoSpam(player, new ChatComponentText(TextHelper.localize(tooltipBase + "currentEssence", currentEssence)));
|
2015-10-30 05:05:00 +00:00
|
|
|
return stack;
|
2015-12-30 20:34:40 +00:00
|
|
|
} else
|
|
|
|
{
|
|
|
|
if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
|
|
|
{
|
2015-10-30 05:05:00 +00:00
|
|
|
TileEntity tile = world.getTileEntity(position.getBlockPos());
|
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
if (tile != null && tile instanceof IBloodAltar)
|
|
|
|
{
|
2015-11-03 16:09:16 +00:00
|
|
|
IBloodAltar altar = (IBloodAltar) tile;
|
|
|
|
int tier = altar.getTier().ordinal() + 1;
|
|
|
|
currentEssence = altar.getCurrentBlood();
|
|
|
|
int capacity = altar.getCapacity();
|
2015-12-03 00:02:18 +00:00
|
|
|
altar.checkTier();
|
2015-11-03 16:09:16 +00:00
|
|
|
ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentAltarTier", tier), TextHelper.localize(tooltipBase + "currentEssence", currentEssence), TextHelper.localize(tooltipBase + "currentAltarCapacity", capacity));
|
2015-12-03 00:02:18 +00:00
|
|
|
|
2016-01-30 13:44:49 +00:00
|
|
|
} else if (tile != null && tile instanceof TileIncenseAltar)
|
|
|
|
{
|
|
|
|
TileIncenseAltar altar = (TileIncenseAltar) tile;
|
|
|
|
double tranquility = altar.tranquility;
|
|
|
|
ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentTranquility", ((int) (100 * tranquility)) / 100d), TextHelper.localize(tooltipBase + "currentBonus", (int) (100 * altar.incenseAddition)));
|
2015-12-30 20:34:40 +00:00
|
|
|
} else
|
|
|
|
{
|
2015-11-03 16:09:16 +00:00
|
|
|
ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentEssence", currentEssence));
|
2015-10-30 05:05:00 +00:00
|
|
|
}
|
2015-11-03 15:34:11 +00:00
|
|
|
|
|
|
|
return stack;
|
2015-10-30 05:05:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
}
|