mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-12-24 17:57:36 +01:00
Clarify code
This commit is contained in:
parent
157be9b679
commit
0b649ff612
@ -65,12 +65,15 @@ public abstract class BaseTouchableLine extends BaseHologramLine implements Stan
|
|||||||
public void setTouchHandler(@Nullable TouchHandler touchHandler) {
|
public void setTouchHandler(@Nullable TouchHandler touchHandler) {
|
||||||
this.touchHandler = touchHandler;
|
this.touchHandler = touchHandler;
|
||||||
|
|
||||||
if (touchHandler != null && slimeEntity == null && super.isSpawned()) {
|
if (touchHandler == null) {
|
||||||
// If the touch handler was null before and no entity has been spawned, spawn it now
|
// Despawn the entity (if existing) since there is no touch handler
|
||||||
spawnSlime(getWorld(), getX(), getY(), getZ());
|
|
||||||
} else if (touchHandler == null) {
|
|
||||||
// Opposite case, the touch handler was not null and an entity was spawned, but now it's useless
|
|
||||||
despawnSlime();
|
despawnSlime();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slimeEntity == null && super.isSpawned()) {
|
||||||
|
// Spawn the entity since it's not spawned
|
||||||
|
spawnSlime(getWorld(), getX(), getY(), getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,8 +104,6 @@ public abstract class BaseTouchableLine extends BaseHologramLine implements Stan
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void spawnSlime(World world, double x, double y, double z) {
|
private void spawnSlime(World world, double x, double y, double z) {
|
||||||
despawnSlime();
|
|
||||||
|
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
try {
|
try {
|
||||||
slimeEntity = getNMSManager().spawnNMSSlime(world, x, getSlimeSpawnY(y), z, this);
|
slimeEntity = getNMSManager().spawnNMSSlime(world, x, getSlimeSpawnY(y), z, this);
|
||||||
|
Loading…
Reference in New Issue
Block a user