Blue
February 17, 2017, 4:11pm
1
How can i do that?
I tried
itemStack.offer(Keys.SPAWNABLE_ENTITY_TYPE, EntityTypes.CREEPER); //does not work
and
Optional<SpawnableData> od = itemStack.get(SpawnableData.class); //not present
(I want to spawn them as an Item somewhere, i just need the color to be colorfull (Easter, you know? :D))
Are you sure that the itemstack is a spawn egg (ItemTypes.SPAWN_EGG
) and that you’re offering back the itemstack to the proper inventory after you modify it?
Blue
February 17, 2017, 11:04pm
3
This is the Code:
ItemStack is = ItemStack.of(ItemTypes.SPAWN_EGG, 1);
is.offer(Keys.DISPLAY_NAME, Text.of("Easter-Egg"));
is.offer(Keys.SPAWNABLE_ENTITY_TYPE, EntityTypes.CREEPER);
Item it = (Item) w.createEntity(EntityTypes.ITEM, pos);
it.offer(Keys.REPRESENTED_ITEM, is.createSnapshot());
it.offer(Keys.INFINITE_DESPAWN_DELAY, true);
it.offer(Keys.INFINITE_PICKUP_DELAY, true);
it.setVelocity(Vector3d.ZERO);
And this is spawned:
(Version is the SpongeVanilla bleeding-branch)
Your code worked perfectly fine for me. Make sure that you’re using the latest SpongeForge for 1.10 or 1.11
Blue
February 17, 2017, 11:17pm
5
I pulled it yesterday into eclipse …
Soo… is it working for you in Sponge-Vanilla? Am I doing sth. wrong? Or is it not implemented there? Or a bug? ^^
(@Aaron1011 because i somehow managed to answer to my own post xD)
Oops - it looks like the SpawnableData implementation hadn’t been updated for 1.11. This should be fixed in the latest SpongeVanilla
1 Like