Jump to content

I can't spawn an entity at my position.


JustinB0406

Recommended Posts

I am trying to have a vanilla entity spawn at my position after I finish drinking a bucket of milk. However, the entity does not spawn when I finish drinking the bucket.

 

public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) {
        if (entityLiving instanceof ServerPlayerEntity) {
            ServerPlayerEntity serverplayerentity = (ServerPlayerEntity)entityLiving;
            CriteriaTriggers.CONSUME_ITEM.trigger(serverplayerentity, stack);
            serverplayerentity.addStat(Stats.ITEM_USED.get(this));
        }

        if (entityLiving instanceof PlayerEntity) {
            stack.shrink(1);
            PlayerEntity p = (PlayerEntity)entityLiving;
            p.getFoodStats().addStats(4, 0.8f);
        }

		//Spawn entity
        if (worldIn.isRemote())
        {
            Entity e = EntityType.create(12, worldIn);
            e.setLocationAndAngles(entityLiving.getPosX(), entityLiving.getPosY(), entityLiving.getPosZ(), 0, 0);
            worldIn.addEntity(e);

        }

        return stack.isEmpty() ? new ItemStack(Items.BUCKET) : stack;
    }

 

I am new at modding, so can anyone help me fix this?

Edited by JustinB0406
Link to comment
Share on other sites

2 minutes ago, diesieben07 said:

You need to spawn entities on the server only. Currently you are spawning it on the client only.

And how do I spawn it on the server?

 

I apologize if what I'm asking is obvious, but I just started modding today.

Edited by JustinB0406
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.