Jump to content

Summon WolfEntity with owner


MoCsabi

Recommended Posts

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

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.