use of net.minecraft.server.v1_16_R2 in project InteractionVisualizer by LOOHP.
the class V1_16_2 method getBoundingBoxes.
public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
net.minecraft.server.v1_16_R2.BlockPosition blockpos = new net.minecraft.server.v1_16_R2.BlockPosition(pos.getX(), pos.getY(), pos.getZ());
WorldServer world = ((CraftWorld) pos.getWorld()).getHandle();
VoxelShape shape = world.getType(blockpos).getShape(world, blockpos);
return shape.d().stream().map(each -> new BoundingBox(each.minX + pos.getX(), each.minY + pos.getY(), each.minZ + pos.getZ(), each.maxX + pos.getX(), each.maxY + pos.getY(), each.maxZ + pos.getZ())).collect(Collectors.toList());
}
use of net.minecraft.server.v1_16_R2 in project InteractionVisualizer by LOOHP.
the class V1_16_2 method createEntityEquipmentPacket.
@Override
public PacketContainer[] createEntityEquipmentPacket(int entityId, List<ValuePairs<EquipmentSlot, ItemStack>> equipments) {
List<Pair<EnumItemSlot, net.minecraft.server.v1_16_R2.ItemStack>> nmsList = new ArrayList<>();
for (ValuePairs<EquipmentSlot, ItemStack> pair : equipments) {
EnumItemSlot nmsSlot;
switch(pair.getFirst()) {
case CHEST:
nmsSlot = EnumItemSlot.CHEST;
break;
case FEET:
nmsSlot = EnumItemSlot.FEET;
break;
case HEAD:
nmsSlot = EnumItemSlot.HEAD;
break;
case LEGS:
nmsSlot = EnumItemSlot.LEGS;
break;
case OFF_HAND:
nmsSlot = EnumItemSlot.OFFHAND;
break;
case HAND:
default:
nmsSlot = EnumItemSlot.MAINHAND;
break;
}
net.minecraft.server.v1_16_R2.ItemStack nmsItem = CraftItemStack.asNMSCopy(pair.getSecond());
nmsList.add(new Pair<>(nmsSlot, nmsItem));
}
PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(entityId, nmsList);
return new PacketContainer[] { PacketContainer.fromPacket(packet) };
}
use of net.minecraft.server.v1_16_R2 in project RoseStacker by Rosewood-Development.
the class NMSHandlerImpl method setItemStackNBT.
@Override
public ItemStack setItemStackNBT(ItemStack itemStack, String key, int value) {
net.minecraft.server.v1_16_R2.ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound tagCompound = nmsItem.getOrCreateTag();
tagCompound.setInt(key, value);
return CraftItemStack.asBukkitCopy(nmsItem);
}
use of net.minecraft.server.v1_16_R2 in project Atlas by funkemunky.
the class BlockBox1_16_R2 method getCollisionBox.
@Override
public CollisionBox getCollisionBox(org.bukkit.block.Block block) {
final net.minecraft.server.v1_16_R2.World world = ((org.bukkit.craftbukkit.v1_16_R2.CraftWorld) block.getWorld()).getHandle();
final int x = block.getX(), y = block.getY(), z = block.getZ();
net.minecraft.server.v1_16_R2.IBlockData iblockData = ((CraftBlock) block).getNMS();
net.minecraft.server.v1_16_R2.Block vblock = iblockData.getBlock();
BlockPosition blockPos = new BlockPosition(x, y, z);
VoxelShape shape = vblock.a(iblockData, world, blockPos, VoxelShapeCollision.a());
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.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ);
} else {
ComplexCollisionBox complexBox = new ComplexCollisionBox();
for (AxisAlignedBB box : boxes) {
complexBox.add(new SimpleCollisionBox(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ));
}
return complexBox;
}
}
use of net.minecraft.server.v1_16_R2 in project SilkSpawners by timbru31.
the class NMSHandler method getSilkSpawnersNBTEntityID.
@Override
@Nullable
public String getSilkSpawnersNBTEntityID(final ItemStack item) {
net.minecraft.server.v1_16_R2.ItemStack itemStack = null;
final CraftItemStack craftStack = CraftItemStack.asCraftCopy(item);
itemStack = CraftItemStack.asNMSCopy(craftStack);
final NBTTagCompound tag = itemStack.getTag();
if (tag == null || !tag.hasKey("SilkSpawners")) {
return null;
}
return tag.getCompound("SilkSpawners").getString("entity");
}
Aggregations