use of net.minecraft.server.v1_13_R1 in project SimplePets by brainsynder-Dev.
the class EntityControllerPet method reloadLocation.
@Override
public void reloadLocation() {
if (displayEntity.getPassenger() != null) {
net.minecraft.server.v1_13_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
Location loc;
if (this.displayRider != null) {
if (this.displayRider.getType().equals(EntityType.SHULKER)) {
loc = getBukkitEntity().getLocation().clone().subtract(0, 0.735, 0);
} else {
loc = getBukkitEntity().getLocation().clone();
}
} else {
loc = getBukkitEntity().getLocation().clone();
}
displayEntity.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
loc.getWorld().getNearbyEntities(loc, 100, 100, 100).forEach(entity -> {
if (entity instanceof Player) {
Player player = (Player) entity;
PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(displayEntity);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
});
return;
}
net.minecraft.server.v1_13_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
Location loc;
if (this.displayRider != null) {
if (this.displayRider.getType().equals(EntityType.SHULKER)) {
loc = getBukkitEntity().getLocation().clone().add(0, 0.75, 0);
} else {
loc = getBukkitEntity().getLocation().clone();
}
} else {
loc = getBukkitEntity().getLocation().clone();
}
displayEntity.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
loc.getWorld().getNearbyEntities(loc, 100, 100, 100).forEach(entity -> {
if (entity instanceof Player) {
Player player = (Player) entity;
PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(displayEntity);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
});
}
use of net.minecraft.server.v1_13_R1 in project TheAPI by TheDevTec.
the class v1_13_R1 method openGUI.
@Override
public void openGUI(Player player, Object container, String legacy, int size, String title, ItemStack[] items) {
EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
int id = ((Container) container).windowId;
net.minecraft.server.v1_13_R1.ItemStack[] nmsItems = new net.minecraft.server.v1_13_R1.ItemStack[items.length];
for (int i = 0; i < items.length; ++i) {
ItemStack is = items[i];
if (is == null || is.getType() == Material.AIR)
continue;
net.minecraft.server.v1_13_R1.ItemStack item = null;
((Container) container).setItem(i, item = (net.minecraft.server.v1_13_R1.ItemStack) asNMSItem(is));
nmsItems[i] = item;
}
BukkitLoader.getPacketHandler().send(player, packetOpenWindow(id, legacy, size, title));
int i = 0;
for (net.minecraft.server.v1_13_R1.ItemStack o : nmsItems) BukkitLoader.getPacketHandler().send(player, packetSetSlot(id, i++, o));
nmsPlayer.activeContainer.transferTo((Container) container, (CraftPlayer) player);
nmsPlayer.activeContainer = (Container) container;
((Container) container).addSlotListener(nmsPlayer);
((Container) container).checkReachable = false;
}
use of net.minecraft.server.v1_13_R1 in project TheAPI by TheDevTec.
the class v1_13_R1 method setGUITitle.
@Override
public void setGUITitle(Player player, Object container, String legacy, int size, String title) {
EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
int id = ((Container) container).windowId;
NonNullList<net.minecraft.server.v1_13_R1.ItemStack> nmsItems = ((Container) container).items;
BukkitLoader.getPacketHandler().send(player, packetOpenWindow(id, legacy, size, title));
int i = 0;
for (net.minecraft.server.v1_13_R1.ItemStack o : nmsItems) BukkitLoader.getPacketHandler().send(player, packetSetSlot(id, i++, o));
nmsPlayer.activeContainer = (Container) container;
((Container) container).addSlotListener(nmsPlayer);
((Container) container).checkReachable = false;
}
use of net.minecraft.server.v1_13_R1 in project TheAPI by TheDevTec.
the class v1_13_R1 method setBlock.
@Override
public void setBlock(Object chunk, int x, int y, int z, Object IblockData, int data) {
net.minecraft.server.v1_13_R1.Chunk c = (net.minecraft.server.v1_13_R1.Chunk) chunk;
ChunkSection sc = c.getSections()[y >> 4];
if (sc == null) {
c.getSections()[y >> 4] = sc = new ChunkSection(y >> 4 << 4, true);
}
BlockPosition pos = new BlockPosition(x, y, z);
// REMOVE TILE ENTITY
c.tileEntities.remove(pos);
try {
DataBits bits = (DataBits) dataBits.get(sc.getBlocks());
@SuppressWarnings("unchecked") DataPalette<IBlockData> pallete = (DataPalette<IBlockData>) dataPallete.get(sc.getBlocks());
bits.a(b(x & 15, y & 15, z & 15), pallete.a((IBlockData) IblockData));
} catch (Exception er) {
}
// ADD TILE ENTITY
if (IblockData instanceof ITileEntity) {
TileEntity ent = ((ITileEntity) IblockData).a(c);
c.tileEntities.put(pos, ent);
Object packet = ent.getUpdatePacket();
Bukkit.getOnlinePlayers().forEach(player -> BukkitLoader.getPacketHandler().send(player, packet));
}
}
use of net.minecraft.server.v1_13_R1 in project Atlas by funkemunky.
the class BlockBox1_13_R1 method getCollisionBox.
@Override
public CollisionBox getCollisionBox(Block block) {
final net.minecraft.server.v1_13_R1.World world = ((org.bukkit.craftbukkit.v1_13_R1.CraftWorld) block.getWorld()).getHandle();
final int x = block.getX(), y = block.getY(), z = block.getZ();
net.minecraft.server.v1_13_R1.IBlockData iblockData = ((CraftBlock) block).getNMS();
net.minecraft.server.v1_13_R1.Block vblock = iblockData.getBlock();
BlockPosition blockPos = new BlockPosition(x, y, z);
VoxelShape shape = vblock.a(iblockData, (IBlockAccess) world, blockPos);
List<AxisAlignedBB> boxes = shape.d();
if (boxes.size() == 0) {
return BlockData.getData(block.getType()).getBox(block, ProtocolVersion.getGameVersion());
} else if (boxes.size() == 1) {
AxisAlignedBB box = boxes.get(0);
return new SimpleCollisionBox(box.a, box.b, box.c, box.d, box.e, box.f);
} else {
ComplexCollisionBox complexBox = new ComplexCollisionBox();
for (AxisAlignedBB box : boxes) {
complexBox.add(new SimpleCollisionBox(box.a, box.b, box.c, box.d, box.e, box.f));
}
return complexBox;
}
}
Aggregations