Spawning the Same horse Twice

Discussion in 'Plugin Development' started by blok601, Apr 16, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    blok601

    Hello Everyone!

    I just have a quick question. I need to spawn the exact same horse with the same variant, speed, etc twice. This is just to make sure that both players have an equal chance. Is there any way to do this?

    Thanks!
     
  2. Offline

    Gonmarte

    1-I actually never needed to use repeating tasks in any of my projects, but i think its a way.
    2-You can just do a double spawn. Repeat the same line of code that you use to spawn an entity twice :)
     
  3. Offline

    Zombie_Striker

    @blok601
    1. Get the first horse instance,
    2. Spawn in another horse.
    3. For every value you want to keep the same, set the second horse's values to be the same as the first's.
     
  4. Offline

    blok601

    What do you mean by get an Instance?

    @Zombie_Striker

    1. I wouldn't use a repeating task, I would just do a for loop.
    2. That doesn't make the second horse have the same attributes.

    @Gonmarte
     
  5. Offline

    Zombie_Striker

    @blok601
    That simply means you need to get the entities instance. I.E[code =java]Entiy horse = [THE INSTANCE][/code] When you spawn a horse, it already returns an instance of that horse, so you can use the following to get the horse's instance.[code =java]Entiy horse = World.spawnEntity(HORSEDATA)[/code]
     
  6. Offline

    Davesan

    May you should copy the NBT data dinamically without caring whatever the data is, then all the attributes of the horses will be the same. Also, with NMS anything can be done... or with reflection, but's really a hard way to go. I think NBT is the easiest way to clone entities. As I remember there is a way to handle NBT, but it was a bit interesting for me when I worked with it.
     
  7. Offline

    blok601

    So just copy their NBT data and use that for the other horse when I am spawning it in?
     
  8. Offline

    Davesan

    Yeah, don't know if you can set the same NBTCompound object for both entity objects, I think not, because it is copied automatically into another data format, but basically that's the idea. I think you should spawn a horse the simple way, and then overwrite its NBT data. If it does not get updated, then you can remove and spawn the entity manually.. maybe? Sadly I've got hardly any time to check anything, since I've got my exams, but it seems possible to copy the entity data. It must be possible, just requires a bit of a research :p
     
Thread Status:
Not open for further replies.

Share This Page