Search in sources :

Example 36 with CraftWorld

use of org.bukkit.craftbukkit.v1_13_R1.CraftWorld in project SilkSpawners by timbru31.

the class NMSHandler method spawnEntity.

@SuppressWarnings("resource")
@Override
public void spawnEntity(final org.bukkit.World w, final String entityID, final double x, final double y, final double z, final Player player) {
    final NBTTagCompound tag = new NBTTagCompound();
    tag.setString("id", entityID);
    final World world = ((CraftWorld) w).getHandle();
    final Optional<Entity> entity = EntityTypes.a(tag, world);
    if (!entity.isPresent()) {
        Bukkit.getLogger().warning("[SilkSpawners] Failed to spawn, falling through. You should report this (entity == null)!");
        return;
    }
    final float yaw = world.random.nextFloat() * (-180 - 180) + 180;
    entity.get().setPositionRotation(x, y, z, yaw, 0);
    world.addEntity(entity.get(), SpawnReason.SPAWNER_EGG);
    final PacketPlayOutEntityHeadRotation rotation = new PacketPlayOutEntityHeadRotation(entity.get(), (byte) yaw);
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(rotation);
}
Also used : Entity(net.minecraft.server.v1_15_R1.Entity) NBTTagCompound(net.minecraft.server.v1_15_R1.NBTTagCompound) PacketPlayOutEntityHeadRotation(net.minecraft.server.v1_15_R1.PacketPlayOutEntityHeadRotation) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) World(net.minecraft.server.v1_15_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld)

Example 37 with CraftWorld

use of org.bukkit.craftbukkit.v1_13_R1.CraftWorld in project SilkSpawners by timbru31.

the class NMSHandler method spawnEntity.

@SuppressWarnings("resource")
@Override
public void spawnEntity(final org.bukkit.World w, final String entityID, final double x, final double y, final double z, final Player player) {
    final NBTTagCompound tag = new NBTTagCompound();
    tag.setString("id", entityID);
    final World world = ((CraftWorld) w).getHandle();
    final Optional<Entity> entity = EntityTypes.a(tag, world);
    if (!entity.isPresent()) {
        Bukkit.getLogger().warning("[SilkSpawners] Failed to spawn, falling through. You should report this (entity == null)!");
        return;
    }
    final float yaw = world.random.nextFloat() * (-180 - 180) + 180;
    entity.get().setPositionRotation(x, y, z, yaw, 0);
    world.addEntity(entity.get(), SpawnReason.SPAWNER_EGG);
    final PacketPlayOutEntityHeadRotation rotation = new PacketPlayOutEntityHeadRotation(entity.get(), (byte) yaw);
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(rotation);
}
Also used : Entity(net.minecraft.server.v1_16_R2.Entity) NBTTagCompound(net.minecraft.server.v1_16_R2.NBTTagCompound) PacketPlayOutEntityHeadRotation(net.minecraft.server.v1_16_R2.PacketPlayOutEntityHeadRotation) CraftPlayer(org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer) World(net.minecraft.server.v1_16_R2.World) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld)

Example 38 with CraftWorld

use of org.bukkit.craftbukkit.v1_13_R1.CraftWorld in project SilkSpawners by timbru31.

the class NMSHandler method spawnEntity.

@SuppressWarnings("resource")
@Override
public void spawnEntity(final org.bukkit.World w, final String entityID, final double x, final double y, final double z, final Player player) {
    final CompoundTag tag = new CompoundTag();
    tag.putString("id", entityID);
    final ServerLevel world = ((CraftWorld) w).getHandle();
    final Optional<Entity> entity = EntityType.create(tag, world);
    if (!entity.isPresent()) {
        Bukkit.getLogger().warning("[SilkSpawners] Failed to spawn, falling through. You should report this (entity == null)!");
        return;
    }
    final float yaw = world.random.nextFloat() * (-180 - 180) + 180;
    entity.get().moveTo(x, y, z, yaw, 0);
    ((CraftWorld) w).addEntity(entity.get(), SpawnReason.SPAWNER_EGG);
    final Packet<ClientGamePacketListener> rotationPacket = new ClientboundRotateHeadPacket(entity.get(), (byte) yaw);
    final ServerPlayerConnection connection = ((CraftPlayer) player).getHandle().connection;
    connection.send(rotationPacket);
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) SpawnerBlockEntity(net.minecraft.world.level.block.entity.SpawnerBlockEntity) Entity(net.minecraft.world.entity.Entity) ServerPlayerConnection(net.minecraft.server.network.ServerPlayerConnection) ClientboundRotateHeadPacket(net.minecraft.network.protocol.game.ClientboundRotateHeadPacket) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld) CompoundTag(net.minecraft.nbt.CompoundTag) ClientGamePacketListener(net.minecraft.network.protocol.game.ClientGamePacketListener)

Example 39 with CraftWorld

use of org.bukkit.craftbukkit.v1_13_R1.CraftWorld in project SilkSpawners by timbru31.

the class NMSHandler method spawnEntity.

@Override
public void spawnEntity(final org.bukkit.World w, final String entityID, final double x, final double y, final double z, final Player player) {
    final NBTTagCompound tag = new NBTTagCompound();
    tag.setString("id", entityID);
    final World world = ((CraftWorld) w).getHandle();
    final Entity entity = EntityTypes.a(tag, world);
    if (entity == null) {
        Bukkit.getLogger().warning("[SilkSpawners] Failed to spawn, falling through. You should report this (entity == null)!");
        return;
    }
    final float yaw = world.random.nextFloat() * (-180 - 180) + 180;
    entity.setPositionRotation(x, y, z, yaw, 0);
    world.addEntity(entity, SpawnReason.SPAWNER_EGG);
    final PacketPlayOutEntityHeadRotation rotation = new PacketPlayOutEntityHeadRotation(entity, (byte) yaw);
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(rotation);
}
Also used : Entity(net.minecraft.server.v1_8_R1.Entity) NBTTagCompound(net.minecraft.server.v1_8_R1.NBTTagCompound) PacketPlayOutEntityHeadRotation(net.minecraft.server.v1_8_R1.PacketPlayOutEntityHeadRotation) CraftPlayer(org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer) World(net.minecraft.server.v1_8_R1.World) CraftWorld(org.bukkit.craftbukkit.v1_8_R1.CraftWorld) CraftWorld(org.bukkit.craftbukkit.v1_8_R1.CraftWorld)

Example 40 with CraftWorld

use of org.bukkit.craftbukkit.v1_13_R1.CraftWorld in project SilkSpawners by timbru31.

the class NMSHandler method spawnEntity.

@SuppressWarnings("resource")
@Override
public void spawnEntity(final org.bukkit.World w, final String entityID, final double x, final double y, final double z, final Player player) {
    final CompoundTag tag = new CompoundTag();
    tag.putString("id", entityID);
    final ServerLevel world = ((CraftWorld) w).getHandle();
    final Optional<Entity> entity = EntityType.create(tag, world);
    if (!entity.isPresent()) {
        Bukkit.getLogger().warning("[SilkSpawners] Failed to spawn, falling through. You should report this (entity == null)!");
        return;
    }
    final float yaw = world.random.nextFloat() * (-180 - 180) + 180;
    entity.get().moveTo(x, y, z, yaw, 0);
    ((CraftWorld) w).addEntity(entity.get(), SpawnReason.SPAWNER_EGG);
    final Packet<ClientGamePacketListener> rotationPacket = new ClientboundRotateHeadPacket(entity.get(), (byte) yaw);
    final ServerPlayerConnection connection = ((CraftPlayer) player).getHandle().connection;
    connection.send(rotationPacket);
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) SpawnerBlockEntity(net.minecraft.world.level.block.entity.SpawnerBlockEntity) Entity(net.minecraft.world.entity.Entity) ServerPlayerConnection(net.minecraft.server.network.ServerPlayerConnection) ClientboundRotateHeadPacket(net.minecraft.network.protocol.game.ClientboundRotateHeadPacket) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld) CompoundTag(net.minecraft.nbt.CompoundTag) ClientGamePacketListener(net.minecraft.network.protocol.game.ClientGamePacketListener)

Aggregations

ServerLevel (net.minecraft.server.level.ServerLevel)147 Location (org.bukkit.Location)131 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)111 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)103 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)95 BlockPos (net.minecraft.core.BlockPos)83 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)74 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)66 ItemStack (org.bukkit.inventory.ItemStack)61 Block (org.bukkit.block.Block)57 LivingEntity (org.bukkit.entity.LivingEntity)54 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)53 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)47 ArrayList (java.util.ArrayList)43 World (org.bukkit.World)41 CraftWorld (org.bukkit.craftbukkit.v1_11_R1.CraftWorld)39 Entity (org.bukkit.entity.Entity)39 Level (net.minecraft.world.level.Level)38 List (java.util.List)34 GameProfile (com.mojang.authlib.GameProfile)32