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;
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.ActionResult;
|
2016-11-11 16:57:50 -08:00
|
|
|
import net.minecraft.util.EnumActionResult;
|
2016-03-18 15:00:23 -04:00
|
|
|
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;
|
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;
|
2016-09-13 17:20:35 -04:00
|
|
|
import WayofTime.bloodmagic.tile.TileInversionPillar;
|
2015-11-02 12:39:44 -08:00
|
|
|
import WayofTime.bloodmagic.util.ChatUtil;
|
2016-06-02 19:09:02 -04:00
|
|
|
import WayofTime.bloodmagic.util.helper.NumeralHelper;
|
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
|
|
|
{
|
2016-10-22 16:52:35 -04:00
|
|
|
// if (world instanceof WorldServer)
|
|
|
|
// {
|
|
|
|
// System.out.println("Testing...");
|
|
|
|
//// BuildTestStructure s = new BuildTestStructure();
|
|
|
|
//// s.placeStructureAtPosition(new Random(), Rotation.CLOCKWISE_180, (WorldServer) world, player.getPosition(), 0);
|
|
|
|
// DungeonTester.testDungeonElementWithOutput((WorldServer) world, player.getPosition());
|
|
|
|
// }
|
2016-09-13 17:20:35 -04:00
|
|
|
|
2016-09-22 14:20:05 -04:00
|
|
|
// if (!world.isRemote)
|
|
|
|
// {
|
|
|
|
// EntityCorruptedSheep fred = new EntityCorruptedSheep(world, EnumDemonWillType.DESTRUCTIVE);
|
|
|
|
// fred.setPosition(player.posX, player.posY, player.posZ);
|
|
|
|
// world.spawnEntityInWorld(fred);
|
|
|
|
// }
|
2016-08-22 14:22:18 -04:00
|
|
|
|
2016-11-11 16:57:50 -08:00
|
|
|
if (PlayerHelper.isFakePlayer(player))
|
|
|
|
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
|
|
|
|
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-04-24 10:06:28 -07:00
|
|
|
RayTraceResult position = rayTrace(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-06-02 17:03:21 -07:00
|
|
|
int currentEssence = altar.getCurrentBlood();
|
|
|
|
int capacity = altar.getCapacity();
|
|
|
|
altar.checkTier();
|
|
|
|
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)));
|
2016-09-13 17:20:35 -04:00
|
|
|
} else if (tile != null && tile instanceof TileInversionPillar)
|
|
|
|
{
|
|
|
|
TileInversionPillar pillar = (TileInversionPillar) tile;
|
|
|
|
double inversion = pillar.getCurrentInversion();
|
|
|
|
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentInversion", ((int) (10 * inversion)) / 10d));
|
2015-12-30 15:34:40 -05:00
|
|
|
} else
|
2016-09-13 17:20:35 -04:00
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
}
|