use of net.minecraft.server.v1_16_R2.World 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);
}
use of net.minecraft.server.v1_16_R2.World 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);
}
use of net.minecraft.server.v1_16_R2.World in project Movecraft by APDevTeam.
the class IWorldHandler method setBlockFast.
@Override
public void setBlockFast(@NotNull Location location, @NotNull MovecraftRotation rotation, @NotNull BlockData data) {
IBlockData blockData;
if (data instanceof CraftBlockData) {
blockData = ((CraftBlockData) data).getState();
} else {
blockData = (IBlockData) data;
}
blockData = blockData.a(ROTATION[rotation.ordinal()]);
World world = ((CraftWorld) (location.getWorld())).getHandle();
BlockPosition blockPosition = locationToPosition(bukkit2MovecraftLoc(location));
setBlockFast(world, blockPosition, blockData);
}
use of net.minecraft.server.v1_16_R2.World in project Movecraft by APDevTeam.
the class IWorldHandler method setBlockFast.
@Override
public void setBlockFast(@NotNull Location location, @NotNull MovecraftRotation rotation, @NotNull BlockData data) {
IBlockData blockData;
if (data instanceof CraftBlockData) {
blockData = ((CraftBlockData) data).getState();
} else {
blockData = (IBlockData) data;
}
blockData = blockData.a(ROTATION[rotation.ordinal()]);
World world = ((CraftWorld) (location.getWorld())).getHandle();
BlockPosition blockPosition = locationToPosition(bukkit2MovecraftLoc(location));
setBlockFast(world, blockPosition, blockData);
}
use of net.minecraft.server.v1_16_R2.World in project Slabbo by Sven65.
the class SlabboAPI_v1_8_R1 method setChestName.
public void setChestName(Block chestBlock, String name) {
Chest chest = (Chest) chestBlock.getState();
World nmsWorld = ((CraftWorld) chestBlock.getWorld()).getHandle();
TileEntity tileEntity = nmsWorld.getTileEntity(new BlockPosition(chestBlock.getX(), chestBlock.getY(), chestBlock.getZ()));
if (!(tileEntity instanceof TileEntityChest))
return;
((TileEntityChest) tileEntity).a(name);
chest.update();
}
Aggregations