2015-11-02 20:39:44 +00:00
|
|
|
package WayofTime.bloodmagic.item.sigil;
|
2015-10-30 05:05:00 +00:00
|
|
|
|
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;
|
|
|
|
import WayofTime.bloodmagic.api.iface.ISigil;
|
2015-11-02 20:39:44 +00:00
|
|
|
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
|
|
|
|
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
|
|
|
import WayofTime.bloodmagic.util.ChatUtil;
|
|
|
|
import WayofTime.bloodmagic.util.helper.TextHelper;
|
2015-10-30 05:05:00 +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;
|
|
|
|
|
2015-11-03 16:09:16 +00:00
|
|
|
public class ItemSigilDivination extends ItemSigilBase implements ISigil, IAltarReader {
|
2015-10-30 05:05:00 +00:00
|
|
|
|
|
|
|
public ItemSigilDivination() {
|
|
|
|
super("divination");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
|
|
|
super.onItemRightClick(stack, world, player);
|
|
|
|
|
2015-11-22 21:43:15 +00:00
|
|
|
if (!world.isRemote) {
|
2015-10-30 05:05:00 +00:00
|
|
|
MovingObjectPosition position = getMovingObjectPositionFromPlayer(world, player, false);
|
2015-11-22 21:43:15 +00:00
|
|
|
int currentEssence = NetworkHelper.getSoulNetwork(BindableHelper.getOwnerName(stack), world).getCurrentEssence();
|
2015-10-30 05:05:00 +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-11-03 16:09:16 +00:00
|
|
|
} else {
|
2015-10-30 05:05:00 +00:00
|
|
|
if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
2015-11-03 15:34:11 +00:00
|
|
|
|
2015-10-30 05:05:00 +00:00
|
|
|
TileEntity tile = world.getTileEntity(position.getBlockPos());
|
|
|
|
|
2015-11-03 16:09:16 +00:00
|
|
|
if (tile != null && tile instanceof IBloodAltar) {
|
|
|
|
IBloodAltar altar = (IBloodAltar) tile;
|
|
|
|
int tier = altar.getTier().ordinal() + 1;
|
|
|
|
currentEssence = altar.getCurrentBlood();
|
|
|
|
int capacity = altar.getCapacity();
|
2015-11-03 15:34:11 +00:00
|
|
|
|
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));
|
|
|
|
} else {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|