Waystones (Fabric Edition)

Waystones (Fabric Edition)

3M Downloads

Bound Scrolls should work whether the player has discovered the bound waypoint or not

Jack-0-Spades opened this issue ยท 2 comments

commented

Excited to show my friend my new base. I teleport to his house and hand him a bound scroll that I had made and bound to my waystone. When he tried to use it though, he got an error that "the bound waystone had been destroyed or removed." Confused I took it back and used it myself. It worked fine. This was disappointing as I had hoped the bound scrolls fixed the one feature I have always felt Waystones to be lacking: a way to share discovered waystones. If this is working as intended please treat this as a request instead. Thank you as always for this mod and all the work you do.

commented

I wrote a book-long post, then deleted it and just posted this instead. Hope you like it.

    @Override
    public ItemStack onItemUseFinish(ItemStack itemStack, World world, EntityLivingBase entity)
    {
        if (!world.isRemote && entity instanceof EntityPlayer)
        {
            EntityPlayer player = (EntityPlayer) entity;

            WaystoneEntry boundTo = getBoundTo(player, itemStack);
            if (boundTo != null)
            {
                double distance = entity.getDistance(boundTo.getPos().getX(), boundTo.getPos().getY(), boundTo.getPos().getZ());
                if (distance <= 2)
                {
                    return itemStack;
                }

                TileWaystone tileWaystone = WaystoneManager.getWaystoneInWorld(boundTo);
                if (tileWaystone != null) //If it's going to fail, it should fail here.  If it fails inside this block, I (Laike Endaril) messed up Blay's mod :P
                {
                    if (!player.capabilities.isCreativeMode) itemStack.shrink(1);

                    WaystoneManager.addPlayerWaystone(player, boundTo);
                    WaystoneManager.sendPlayerWaystones(player);

                    if (!WaystoneManager.teleportToWaystone(player, boundTo))
                    {
                        System.err.println("Bound scroll failed in the wrong way!  This should never happen, and you should go find Laike Endaril and tell him that he sucks.");
                    }
                }
            }
        }

        return itemStack;
    }

Edit: I'll try to figure out the pull request process after work today; never done one before

commented

Very glad to see this. I've been trying to find a way to use the better questing system to teleport players to a Waystone they haven't found yet and I was having a huge problem doing so. If I can give them a bound page that should be perfect. Very Excited for the next update now. :)