2015-11-02 12:39:44 -08:00
|
|
|
package WayofTime.bloodmagic.item.sigil;
|
2015-10-29 22:05:00 -07:00
|
|
|
|
2016-03-18 15:00:23 -04:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2016-04-17 13:51:39 -07:00
|
|
|
import WayofTime.bloodmagic.util.helper.NumeralHelper;
|
2016-03-18 15:00:23 -04:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.ActionResult;
|
|
|
|
import net.minecraft.util.EnumHand;
|
|
|
|
import net.minecraft.util.math.RayTraceResult;
|
|
|
|
import net.minecraft.util.text.ITextComponent;
|
2016-04-02 21:44:50 -04:00
|
|
|
import net.minecraft.util.text.TextComponentTranslation;
|
2016-03-18 15:00:23 -04:00
|
|
|
import net.minecraft.world.World;
|
2016-01-30 08:44:49 -05:00
|
|
|
import WayofTime.bloodmagic.api.Constants;
|
2015-11-02 12:39:44 -08:00
|
|
|
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
2015-11-03 10:34:11 -05:00
|
|
|
import WayofTime.bloodmagic.api.iface.IAltarReader;
|
2015-11-02 12:39:44 -08:00
|
|
|
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
2016-02-11 15:44:32 -05:00
|
|
|
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
2016-01-30 08:44:49 -05:00
|
|
|
import WayofTime.bloodmagic.tile.TileIncenseAltar;
|
2015-11-02 12:39:44 -08:00
|
|
|
import WayofTime.bloodmagic.util.ChatUtil;
|
2015-10-29 22:05:00 -07:00
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
public class ItemSigilDivination extends ItemSigilBase implements IAltarReader
|
|
|
|
{
|
|
|
|
public ItemSigilDivination()
|
|
|
|
{
|
2015-10-29 22:05:00 -07:00
|
|
|
super("divination");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-03-18 15:00:23 -04:00
|
|
|
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
|
2015-12-30 15:34:40 -05:00
|
|
|
{
|
|
|
|
if (!world.isRemote)
|
|
|
|
{
|
2016-03-28 07:25:51 -04:00
|
|
|
super.onItemRightClick(stack, world, player, hand);
|
2016-04-02 21:44:50 -04:00
|
|
|
|
2016-03-18 15:00:23 -04:00
|
|
|
RayTraceResult position = getMovingObjectPositionFromPlayer(world, player, false);
|
2015-10-29 22:05:00 -07:00
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
if (position == null)
|
|
|
|
{
|
2016-02-11 15:44:32 -05:00
|
|
|
int currentEssence = NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).getCurrentEssence();
|
2016-03-18 15:00:23 -04:00
|
|
|
List<ITextComponent> toSend = new ArrayList<ITextComponent>();
|
2016-02-05 18:05:44 -08:00
|
|
|
if (!getOwnerName(stack).equals(PlayerHelper.getUsernameFromPlayer(player)))
|
2016-04-02 21:44:50 -04:00
|
|
|
toSend.add(new TextComponentTranslation(tooltipBase + "otherNetwork", getOwnerName(stack)));
|
|
|
|
toSend.add(new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence));
|
2016-03-18 15:00:23 -04:00
|
|
|
ChatUtil.sendNoSpam(player, toSend.toArray(new ITextComponent[toSend.size()]));
|
2015-12-30 15:34:40 -05:00
|
|
|
} else
|
|
|
|
{
|
2016-03-18 15:00:23 -04:00
|
|
|
if (position.typeOfHit == RayTraceResult.Type.BLOCK)
|
2015-12-30 15:34:40 -05:00
|
|
|
{
|
2015-10-29 22:05:00 -07:00
|
|
|
TileEntity tile = world.getTileEntity(position.getBlockPos());
|
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
if (tile != null && tile instanceof IBloodAltar)
|
|
|
|
{
|
2015-11-03 08:09:16 -08:00
|
|
|
IBloodAltar altar = (IBloodAltar) tile;
|
|
|
|
int tier = altar.getTier().ordinal() + 1;
|
2016-02-11 15:44:32 -05:00
|
|
|
int currentEssence = altar.getCurrentBlood();
|
2015-11-03 08:09:16 -08:00
|
|
|
int capacity = altar.getCapacity();
|
2015-12-02 16:02:18 -08:00
|
|
|
altar.checkTier();
|
2016-04-17 13:51:39 -07:00
|
|
|
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentAltarTier", NumeralHelper.toRoman(tier)), new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence), new TextComponentTranslation(tooltipBase + "currentAltarCapacity", capacity));
|
2016-01-30 08:44:49 -05:00
|
|
|
} else if (tile != null && tile instanceof TileIncenseAltar)
|
|
|
|
{
|
|
|
|
TileIncenseAltar altar = (TileIncenseAltar) tile;
|
2016-02-09 18:13:18 -05:00
|
|
|
altar.recheckConstruction();
|
2016-01-30 08:44:49 -05:00
|
|
|
double tranquility = altar.tranquility;
|
2016-04-02 21:44:50 -04:00
|
|
|
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentTranquility", (int) ((100D * (int) (100 * tranquility)) / 100d)), new TextComponentTranslation(tooltipBase + "currentBonus", (int) (100 * altar.incenseAddition)));
|
2015-12-30 15:34:40 -05:00
|
|
|
} else
|
|
|
|
{
|
2016-02-11 15:44:32 -05:00
|
|
|
int currentEssence = NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).getCurrentEssence();
|
2016-04-02 21:44:50 -04:00
|
|
|
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence));
|
2015-10-29 22:05:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-18 15:00:23 -04:00
|
|
|
return super.onItemRightClick(stack, world, player, hand);
|
2015-10-29 22:05:00 -07:00
|
|
|
}
|
|
|
|
}
|