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

How can i get the player who spawned the mob. Is it would be correct to find a player by distance like this. it is wotking but is it correct?

@Override
public ILivingEntityData onInitialSpawn(IServerWorld worldIn, DifficultyInstance difficultyIn, SpawnReason reason, @Nullable ILivingEntityData spawnDataIn, @Nullable CompoundNBT dataTag) {
    float dist = 999999999;
    int pl = 0;
    if (reason == SpawnReason.COMMAND || reason == SpawnReason.SPAWN_EGG || reason == SpawnReason.SPAWNER || reason == SpawnReason.DISPENSER) {
        List<ServerPlayerEntity> players = worldIn.getWorld().getPlayers();
       for(int i = 0;i < players.size();i++)
       {
           if ( dist > this.getDistance(players.get(i)))
           {
               dist = this.getDistance(players.get(i));
           pl = i;
           }
       }
        this.setCustomName(new TranslationTextComponent(players.get(pl).getScoreboardName()));

    }
    return super.onInitialSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag);
}

 

 

  • Author

I spawned the mod with this code. Is this count as spawn eggs?

entityType.spawn(spawnWorld,null,null,pos, SpawnReason.SPAWN_EGG,true,true);
  • Author

Like this ?
 

ItemStack is = new ItemStack(null);
is.setDisplayName(new TranslationTextComponent(ctx.get().getSender().getScoreboardName()));
entityType.spawn(spawnWorld,is,null,pos, SpawnReason.SPAWN_EGG,true,true);
  • Author

like this? 
 

Entity e =  entityType.spawn(spawnWorld,null,null,pos, SpawnReason.SPAWN_EGG,true,true);
e.setCustomName(new TranslationTextComponent(ctx.get().getSender().getScoreboardName()));

Edited by Klarks

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.