use of net.minecraft.server.v1_13_R1.World in project TheAPI by TheDevTec.
the class v1_13_R1 method packetBlockChange.
@Override
public Object packetBlockChange(World world, Position position) {
PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange();
packet.block = (IBlockData) position.getIBlockData();
try {
pos.set(packet, position.getBlockPosition());
} catch (Exception e) {
}
return packet;
}
use of net.minecraft.server.v1_13_R1.World in project PublicCrafters by BananaPuncher714.
the class CustomContainerWorkbench method setCraftResult.
public void setCraftResult() {
if (!world.isClientSide) {
EntityPlayer entityplayer = (EntityPlayer) ((CraftHumanEntity) viewer).getHandle();
ItemStack itemstack = ItemStack.a;
IRecipe irecipe = world.getMinecraftServer().getCraftingManager().b(craftInventory, world);
if ((resultInventory.a(world, entityplayer, irecipe)) && (irecipe != null)) {
resultInventory.a(irecipe);
itemstack = irecipe.craftItem(craftInventory);
}
itemstack = CraftEventFactory.callPreCraftEvent(craftInventory, resultInventory, itemstack, getBukkitView(), false);
resultInventory.setItem(0, itemstack);
entityplayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, 0, itemstack));
for (Object listener : listeners) {
EntityPlayer player = (EntityPlayer) listener;
player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.activeContainer.windowId, 0, itemstack));
}
}
}
use of net.minecraft.server.v1_13_R1.World 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);
}
use of net.minecraft.server.v1_13_R1.World 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);
}
use of net.minecraft.server.v1_13_R1.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);
}
Aggregations