Jump to content

[SOLVED] [1.15.2] Problems with entity spawning


ArcaneDiver

Recommended Posts

Hi, i'm trying to spawn my custom dolphine when i right-click a dolphin, in order to do this when the event fires i remove the vanilla dolphin, instantiate my own and make player ride it.

Here is the code:

@SubscribeEvent
    public static void onDolphinInteract(PlayerInteractEvent.EntityInteract e) {
        if(e.getTarget() instanceof DolphinEntity && e.getTarget() != null) {
            World worldIn = e.getWorld();
            DolphinEntity dolphinEntity = (DolphinEntity) e.getTarget();
            ClientPlayerEntity player = Minecraft.getInstance().player;

            if(player != null && player.getRidingEntity() == null) {
                dolphinEntity.remove();

                RidableDolphinEnitity sobstitue = new RidableDolphinEnitity(worldIn);
                sobstitue.setPosition(dolphinEntity.lastTickPosX, dolphinEntity.lastTickPosY, dolphinEntity.lastTickPosZ);
                worldIn.addEntity(sobstitue);
                player.startRiding(sobstitue);

            }

        }
    }

 

But when i test it and i right-click the dolphine disappear and i'm freezed, where i'm wrong?

Edited by ArcaneDiver
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.