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 want to summon a vanilla-minecraft wolf with an owner set already. I have stored the player's UUID in an nbt tag (on an itemstack), but when I use the setOwnerID() method, the dog wont get a collar, nor can I sit it down. But what is interesting is that it still walks towards me, and telepors if I go away... I tried using updateEntity() method (both on ServerWorld and ClientWorld). If I reopen my world, the dog has a collar, and I can make it sit. I'm kinda new, so this might be terribly obvious.

Thanks in advance!

My code for summoning the entity:

Minecraft instance= Minecraft.getInstance();
ServerWorld sWorld=Minecraft.getInstance().getIntegratedServer().getWorld(instance.player.getEntityWorld().getDimension().getType());
WolfEntity Entity=EntityType.WOLF.create(sWorld);
entity.moveToBlockPosAndAngles(instance.player.getPosition(),0,0);
entity.onInitialSpawn(sWorld, sWorld.getDifficultyForLocation(instance.player.getPosition()), SpawnReason.EVENT, eData, (CompoundNBT)null);
entity.setOwnerId(itemStackWithNBT.getStack().getTag().getUniqueId("owner"));
sWorld.addEntity(entity);
sWorld.updateEntity(entity);
instance.world.updateEntity(entity);
//Sorry for messy code

I also tried debugging using the isOwner() method, it said false.

  • Author

I'm doing this from the detectAndSendChanges() method of a container. I am looking into network pockets. Thanks for your help!

  • Author

But can I use Minecraft.getInstance.getIntegratedServer? Or is there another way of getting the server?

Edited by MoCsabi

  • Author

Well, I need the server world to spawn in the wolf. Or you don’t need the server for the server world?

  • Author

Oh I’m so dumb... so I store the player when he opens the container? ( that’s where I can get it from parameters)

  • Author

Okay, I've done it! It helped a bit, bit its still not perfect.

Now if I Sys.out isOwner(), now it says yes! So the server side is probably good. I'm probably wrong here, but I think that the client side is not working. It's not showing the collar, and not registering my clicks on the wolf, but it still moves towards me (so the serverside works). My new code:

//The player is is the player using
World sWorld=player.world;
WolfEntity entity=EntityType.WOLF.create(sWorld);
entity.moveToBlockPosAndAngles(player.getPosition(),0,0);
entity.onInitialSpawn(sWorld, sWorld.getDifficultyForLocation(player.getPosition()), SpawnReason.EVENT, (ILivingEntityData)null, (CompoundNBT)null);
entity.setOwnerId(itemStackWithNBT.getTag().getUniqueId("owner"));
sWorld.addEntity(entity);

I don't know how to fix this problem...

Edited by MoCsabi

  • Author

Thank you so much for your help!

I copied these from the processInteraction() method!

entity.setTamedBy((PlayerEntity)entity.getOwner());
entity.setAttackTarget((LivingEntity)null);
entity.world.setEntityState(entity, (byte)7);

It's working!

Thank you so much

(Also I don't know how I didn't notice the setTamedBy() method...)

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.