BloodMagic/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilDivination.java

81 lines
3.9 KiB
Java
Raw Normal View History

package WayofTime.bloodmagic.item.sigil;
2015-10-29 22:05:00 -07:00
import java.util.ArrayList;
import java.util.List;
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;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.altar.IBloodAltar;
2015-11-03 10:34:11 -05:00
import WayofTime.bloodmagic.api.iface.IAltarReader;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.tile.TileIncenseAltar;
import WayofTime.bloodmagic.util.ChatUtil;
import WayofTime.bloodmagic.util.helper.TextHelper;
2015-10-29 22:05:00 -07:00
public class ItemSigilDivination extends ItemSigilBase implements IAltarReader
{
public ItemSigilDivination()
{
2015-10-29 22:05:00 -07:00
super("divination");
setRegistryName(Constants.BloodMagicItem.SIGIL_DIVINATION.getRegName());
2015-10-29 22:05:00 -07:00
}
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
if (!world.isRemote)
{
super.onItemRightClick(stack, world, player, hand);
RayTraceResult position = getMovingObjectPositionFromPlayer(world, player, false);
2015-10-29 22:05:00 -07:00
if (position == null)
{
int currentEssence = NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).getCurrentEssence();
System.out.println("Hai~");
List<ITextComponent> toSend = new ArrayList<ITextComponent>();
if (!getOwnerName(stack).equals(PlayerHelper.getUsernameFromPlayer(player)))
toSend.add(new TextComponentString(TextHelper.localize(tooltipBase + "otherNetwork", getOwnerName(stack))));
toSend.add(new TextComponentString(TextHelper.localize(tooltipBase + "currentEssence", currentEssence)));
ChatUtil.sendNoSpam(player, toSend.toArray(new ITextComponent[toSend.size()]));
} else
{
if (position.typeOfHit == RayTraceResult.Type.BLOCK)
{
2015-10-29 22:05:00 -07:00
TileEntity tile = world.getTileEntity(position.getBlockPos());
if (tile != null && tile instanceof IBloodAltar)
{
2015-11-03 08:09:16 -08:00
IBloodAltar altar = (IBloodAltar) tile;
int tier = altar.getTier().ordinal() + 1;
int currentEssence = altar.getCurrentBlood();
2015-11-03 08:09:16 -08:00
int capacity = altar.getCapacity();
altar.checkTier();
2015-11-03 08:09:16 -08:00
ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentAltarTier", tier), TextHelper.localize(tooltipBase + "currentEssence", currentEssence), TextHelper.localize(tooltipBase + "currentAltarCapacity", capacity));
} else if (tile != null && tile instanceof TileIncenseAltar)
{
TileIncenseAltar altar = (TileIncenseAltar) tile;
altar.recheckConstruction();
double tranquility = altar.tranquility;
ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentTranquility", (int) ((100D * (int) (100 * tranquility)) / 100d)), TextHelper.localize(tooltipBase + "currentBonus", (int) (100 * altar.incenseAddition)));
} else
{
int currentEssence = NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).getCurrentEssence();
2015-11-03 08:09:16 -08:00
ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentEssence", currentEssence));
2015-10-29 22:05:00 -07:00
}
}
}
}
return super.onItemRightClick(stack, world, player, hand);
2015-10-29 22:05:00 -07:00
}
}