Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

  • Author
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

  • Author
2 minutes ago, diesieben07 said:

That would make it run on both client and server.

So then I should use if (!worldIn.isRemote()) instead. then?

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.