Posted July 5, 20205 yr 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.
July 5, 20205 yr Author I'm doing this from the detectAndSendChanges() method of a container. I am looking into network pockets. Thanks for your help!
July 5, 20205 yr Author But can I use Minecraft.getInstance.getIntegratedServer? Or is there another way of getting the server? Edited July 5, 20205 yr by MoCsabi
July 5, 20205 yr Author Well, I need the server world to spawn in the wolf. Or you don’t need the server for the server world?
July 5, 20205 yr 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)
July 6, 20205 yr 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 July 6, 20205 yr by MoCsabi
July 6, 20205 yr 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.