bukkit
Entità
Ricerca…
Teletrasporto di un'entità in un'altra entità
Entity entity; //The entity you want to teleport
Entity teleportTo; //The entity where you want <entity> to be teleported to
boolean success = entity.teleport(teleportTo); //Attempting to teleport.
if(success) {
//Teleport was successful
}else {
//Teleport wasn't successful
}
Puoi anche aggiungere una causa al tuo teleporto, in modo da poter personalizzare il modo in cui la causa verrà trattata dal tuo plug-in o da altri:
Entity entity; //The entity you want to teleport
Entity teleportTo; //The entity where you want <entity> to be teleported to
PlayerTeleportEvent.TeleportCause cause; //The cause you want the teleport to be of
boolean success = entity.teleport(teleportTo, cause); //Attempting to teleport.
if(success) {
//Teleport was successful
}else {
//Teleport wasn't successful
}
Teletrasporto di un'entità in una posizione
Entity toBeTeleported; //The entity you want to teleport
Location teleportTo = new Location(world,x,y,z,yaw,pitch); //The location to teleport to
boolean success = toBeTeleported.teleport(teleportTo);
if(success) {
//Teleport was successful
}else {
//Teleport wasn't successful
}
Puoi anche aggiungere una causa al tuo teleporto, in modo da poter personalizzare il modo in cui la causa verrà trattata dal tuo plug-in o da altri:
Entity toBeTeleported; //The entity you want to teleport
Location teleportTo = new Location(world,x,y,z,yaw,pitch); //The location to teleport to
PlayerTeleportEvent.TeleportCause cause; //The cause you want the teleport to be of
boolean success = toBeTeleported.teleport(teleportTo, cause);
if(success) {
//Teleport was successful
}else {
//Teleport wasn't successful
}
Tipo di entità
L'enum EntityType rappresenta tutte le entità di Bukkit / Spigot.
Tutti i suoi valori possono essere trovati sotto.
| Valore | Descrizione |
|---|---|
| AREA_EFFECT_CLOUD | N / A |
| ARMOR_STAND | Entità meccanica con un inventario per l'inserimento di armi / armature. |
| FRECCIA | Un proiettile a freccia; potrebbe rimanere incastrato nel terreno. |
| BAT | N / A |
| FIAMMATA | N / A |
| BARCA | Un posto in barca |
| CAVE_SPIDER | N / A |
| POLLO | N / A |
| COMPLEX_PART | N / A |
| MUCCA | N / A |
| CREEPER | N / A |
| DRAGON_FIREBALL | Come FIREBALL, ma con effetti extra |
| DROPPED_ITEM | Un oggetto appoggiato a terra. |
| UOVO | Un uovo di gallina volante. |
| ENDER_CRYSTAL | N / A |
| ENDER_DRAGON | N / A |
| ENDER_PEARL | Una perla volante. |
| ENDER_SIGNAL | Un segnale d'occhio finale. |
| Enderman | N / A |
| ENDERMITE | N / A |
| EXPERIENCE_ORB | Un'esperienza orb. |
| FALLING_BLOCK | Un blocco che sta per o sta per cadere. |
| BOLIDE | Una grande palla di fuoco volante, come lanciata da un Ghast per esempio. |
| ARTIFICIO | Rappresentazione interna di un fuoco d'artificio una volta che è stato lanciato. |
| AMO | Una lenza e un galleggiante. |
| Ghast | N / A |
| GIGANTE | N / A |
| CUSTODE | N / A |
| CAVALLO | N / A |
| GOLEM DI FERRO | N / A |
| ITEM_FRAME | Una cornice di un oggetto su un muro. |
| LEASH_HITCH | Un guinzaglio attaccato ad un recinto. |
| LIGHTNING | Un fulmine. |
| LINGERING_POTION | Una pozione volante persistente |
| CUBO DI MAGMA | N / A |
| Minecart | N / A |
| MINECART_CHEST | N / A |
| MINECART_COMMAND | N / A |
| MINECART_FURNACE | N / A |
| MINECART_HOPPER | N / A |
| MINECART_MOB_SPAWNER | N / A |
| MINECART_TNT | N / A |
| MUSHROOM_COW | N / A |
| OCELOT | N / A |
| PITTURA | Un dipinto su un muro. |
| MAIALE | N / A |
| PIG_ZOMBIE | N / A |
| GIOCATORE | N / A |
| ORSO POLARE | N / A |
| PRIMED_TNT | TNT innescato che sta per esplodere. |
| CONIGLIO | N / A |
| PECORA | N / A |
| SHULKER | N / A |
| SHULKER_BULLET | Proiettile sparato da SHULKER. |
| pesciolino d'argento | N / A |
| SCHELETRO | N / A |
| SLIME | N / A |
| SMALL_FIREBALL | Una piccola palla di fuoco volante, come lanciata da un Blaze o un giocatore. |
| PALLA DI NEVE | Una palla di neve volante. |
| PUPAZZO DI NEVE | N / A |
| SPECTRAL_ARROW | Come TIPPED_ARROW ma causa l'effetto PotionEffectType.GLOWING su tutti i membri del team. |
| RAGNO | N / A |
| SPLASH_POTION | Una pozione splash splash |
| CALAMARO | N / A |
| THROWN_EXP_BOTTLE | Una bottiglia di esperienza volante. |
| TIPPED_ARROW | Come ARROW ma con una pozione specifica che viene applicata al contatto. |
| SCONOSCIUTO | Un'entità sconosciuta senza una classe di entità |
| CONTADINO | N / A |
| TEMPO METEREOLOGICO | N / A |
| STREGA | N / A |
| APPASSIRE | N / A |
| WITHER_SKULL | Un proiettile di teschio volante wither. |
| LUPO | N / A |
| ZOMBIE | N / A |
Passeggeri
Le entità possono avere passeggeri. Un buon esempio di passeggero è un giocatore che cavalca un maiale sellato o uno zombi all'interno di un carretto.
Sebbene esistano veicoli specifici, qualsiasi entità può essere un veicolo per qualsiasi altra entità con il metodo SetPassenger.
Entity vehicle;
Entity passenger;
boolean result = vehicle.setPassenger(passenger); //False if couldn't be done for whatever reason
Il passeggero dovrebbe ora essere collegato al veicolo
Puoi verificare se un'entità ha un passeggero che usa
boolean hasPassenger = entity.isEmpty()
Se l'entità ha un passeggero, puoi recuperare l'entità passeggero con
Entity passenger = entity.getPassenger();
Restituirà solo il passeggero principale se il veicolo può avere multipli.
Infine, puoi espellere il passeggero di un'entità con
boolean b = entity.eject(); //Eject all passengers - returns true if there was a passenger to be ejected
Entità vicine
Per recuperare un elenco di entità vicine di un'entità, si può usare
List<Entity> nearby = entity.getNearbyEntities(double x, double y, double z);
Bukkit calcolerà quindi una casella di delimitazione centrata attorno all'entità, avente come parametri:
- x: 1/2 la dimensione della scatola lungo l'asse x
- y: 1/2 della dimensione della scatola lungo l'asse y
- z: 1/2 della dimensione della scatola lungo l'asse z
L'elenco potrebbe essere vuoto, il che significa che non ci sono entità vicine con i parametri.
Questo approccio può essere utilizzato per rilevare entità vicino a proiettili personalizzati, ad esempio lanciando un Itemstack e rilevando quando si scontra con un giocatore