Skip to content

Commit

Permalink
Improves DisplayFloatingPet
Browse files Browse the repository at this point in the history
  • Loading branch information
anjoismysign committed Jan 7, 2024
1 parent dcd6385 commit 33f3f08
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 26 deletions.
2 changes: 1 addition & 1 deletion ci-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>us.mytheria</groupId>
<artifactId>BlobLib</artifactId>
<version>1.697.55</version>
<version>1.697.56</version>
<relativePath>pom.xml</relativePath>
</parent>
<artifactId>bloblib</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion local-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>us.mytheria</groupId>
<artifactId>BlobLib</artifactId>
<version>1.697.55</version>
<version>1.697.56</version>
<relativePath>pom.xml</relativePath>
</parent>
<artifactId>bloblib</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>us.mytheria</groupId>
<artifactId>BlobLib</artifactId>
<version>1.697.55</version>
<version>1.697.56</version>
<packaging>pom</packaging>

<properties>
Expand Down Expand Up @@ -50,7 +50,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,8 @@ void spawnEntity(Location location) {
BlobLib plugin = BlobLib.getInstance();
entity = (BlockDisplay) location.getWorld().spawnEntity(location,
EntityType.BLOCK_DISPLAY);
vehicle = (BlockDisplay) location.getWorld().spawnEntity(location,
EntityType.BLOCK_DISPLAY);
entity.setPersistent(false);
vehicle.setPersistent(false);
if (!vehicle.addPassenger(entity)) {
throw new RuntimeException("Failed to add passenger to vehicle");
}
entity.setTeleportDuration(1);
setCustomName(getCustomName());
entity.setBlock(getDisplay());
initAnimations(plugin);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package us.mytheria.bloblib.displayentity;

import me.anjoismysign.manobukkit.entities.decorators.implementations.ManoratorFactory;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Particle;
Expand All @@ -10,18 +9,23 @@
import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import us.mytheria.bloblib.BlobLibAPI;

import java.util.Objects;
import java.util.Random;
import java.util.UUID;

/**
* Represents a FloatingPet.
* Uses 1.20.2+ Bukkit API
*
* @param <T> - the Display entity
* @param <R> - (BlockData/ItemStack)
*/
public abstract class DisplayFloatingPet<T extends Display, R extends Cloneable>
implements DisplayPet<Display, R> {
private static final ManoratorFactory MANORATOR_FACTORY = BlobLibAPI.getInstance().getManoBukkit().getManoratorFactory();

private Particle particle;
protected T entity, vehicle;
protected T entity;
private Location location;
private UUID owner;
private boolean activated, pauseLogic;
Expand Down Expand Up @@ -209,12 +213,9 @@ public String getCustomName() {
* @param loc the new location
*/
public void teleport(Location loc) {
if (vehicle != null) {
loadChunks(location);
loadChunks(loc);
MANORATOR_FACTORY.of(vehicle).vehicleTeleport(loc);
} else
throw new NullPointerException("Expected vehicle is null");
loadChunks(location);
loadChunks(loc);
entity.teleport(loc);
setLocation(loc);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,8 @@ void spawnEntity(Location location) {
BlobLib plugin = BlobLib.getInstance();
entity = (ItemDisplay) location.getWorld().spawnEntity(location,
EntityType.ITEM_DISPLAY);
vehicle = (ItemDisplay) location.getWorld().spawnEntity(location,
EntityType.ITEM_DISPLAY);
entity.setPersistent(false);
vehicle.setPersistent(false);
if (!vehicle.addPassenger(entity)) {
throw new RuntimeException("Failed to add passenger to vehicle");
}
entity.setTeleportDuration(1);
setCustomName(getCustomName());
entity.setItemStack(getDisplay());
Transformation transformation = entity.getTransformation();
Expand Down

0 comments on commit 33f3f08

Please sign in to comment.