Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/by1337/virtualentityapi
VirtualEntityApi is an API for creating packet entities.
https://github.com/by1337/virtualentityapi
bukkit packet-entity packets protocol spigot
Last synced: about 2 months ago
JSON representation
VirtualEntityApi is an API for creating packet entities.
- Host: GitHub
- URL: https://github.com/by1337/virtualentityapi
- Owner: By1337
- License: mit
- Created: 2024-11-15T18:55:27.000Z (2 months ago)
- Default Branch: master
- Last Pushed: 2024-11-27T21:42:20.000Z (about 2 months ago)
- Last Synced: 2024-11-27T22:28:44.255Z (about 2 months ago)
- Topics: bukkit, packet-entity, packets, protocol, spigot
- Language: Java
- Homepage:
- Size: 389 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# VirtualEntityApi
**VirtualEntityApi** is an API for creating packet entities.
### Features:
- **Minimal use of NMS**.
- **Maximum ease of use**.Supported versions: 1.16.5, 1.17.1, 1.18.2, 1.19.4
---
## Example Usage
### Creating a packet mob
```java
public void test(Player player) {
// Create a packet ArmorStand
VirtualArmorStand armorStand = VirtualEntityApi.getFactory().create(VirtualEntityType.ARMOR_STAND, VirtualArmorStand.class);
// Set parameters
armorStand.setCustomName(Component.text("Custom name"));
armorStand.setCustomNameVisible(true);
armorStand.setPos(new Vec3d(player.getLocation()));
armorStand.setNoBasePlate(true);
// Pass the current list of observers
armorStand.tick(Set.of(player));
}
```Working with packet mobs is very similar to working with regular mobs, except for the following differences:
- Packet mobs **do not depend on chunk loading** (whether they are unloaded/loaded).
- They ignore game rules such as `mob-spawning deny`, burning in sunlight, and physics.
- They maintain their position even in the air and do not account for `velocity`.---
### Automatic `tick` invocation with `PlayerTracker`
```java
private void spawn(Location location, Plugin plugin) {
PlayerTracker tracker = new PlayerTracker(location.getWorld(), new Vec3d(location));
VirtualArmorStand armorStand = VirtualEntityApi.getFactory().create(VirtualEntityType.ARMOR_STAND, VirtualArmorStand.class);
armorStand.setCustomName(Component.text("Custom name"));
armorStand.setCustomNameVisible(true);
armorStand.setPos(new Vec3d(location));
tracker.addEntity(armorStand);
BukkitTask task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, tracker::tick, 1, 1);
}
````PlayerTracker` automatically searches for players in the specified world and radius, invoking `tick` for the entities.
---
## Integration
### Maven
```xml
by1337-repo
https://repo.by1337.space/repository/maven-releases/
dev.by1337.virtualentity.api
VirtualEntityApi-api
1.0
provided```
### Gradle
```groovy
repositories {
maven {
name = "by1337-repo"
url = "https://repo.by1337.space/repository/maven-releases/"
}
}dependencies {
compileOnly 'dev.by1337.virtualentity.api:VirtualEntityApi-api:1.0'
}
```---
### License
[MIT](LICENSE)