mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2025-03-02 10:41:04 +01:00
Small fixes.
This commit is contained in:
parent
df54bd3c54
commit
8ea4488028
@ -96,7 +96,6 @@ public interface FloatingItem {
|
|||||||
*/
|
*/
|
||||||
public boolean hasPickupHandler();
|
public boolean hasPickupHandler();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the timestamp of when the floating item was created, in milliseconds.
|
* @return the timestamp of when the floating item was created, in milliseconds.
|
||||||
*/
|
*/
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
|
|||||||
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.HologramWitherSkull;
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramWitherSkull;
|
||||||
import com.gmail.filoghost.holograms.object.HologramBase;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
import com.gmail.filoghost.holograms.utils.GenericUtils;
|
||||||
|
|
||||||
import net.minecraft.server.v1_6_R3.Entity;
|
import net.minecraft.server.v1_6_R3.Entity;
|
||||||
import net.minecraft.server.v1_6_R3.EntityWitherSkull;
|
import net.minecraft.server.v1_6_R3.EntityWitherSkull;
|
||||||
@ -120,7 +121,7 @@ public class EntityHologramWitherSkull extends EntityWitherSkull implements Holo
|
|||||||
if (obj instanceof EntityPlayer) {
|
if (obj instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||||
|
|
||||||
double distanceSquared = nmsPlayer.e(locX, locY, locZ);
|
double distanceSquared = GenericUtils.square(nmsPlayer.locX - this.locX) + GenericUtils.square(nmsPlayer.locZ - this.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
|||||||
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.HologramWitherSkull;
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramWitherSkull;
|
||||||
import com.gmail.filoghost.holograms.object.HologramBase;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
import com.gmail.filoghost.holograms.utils.GenericUtils;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R1.Entity;
|
import net.minecraft.server.v1_7_R1.Entity;
|
||||||
import net.minecraft.server.v1_7_R1.EntityWitherSkull;
|
import net.minecraft.server.v1_7_R1.EntityWitherSkull;
|
||||||
@ -120,7 +121,7 @@ public class EntityHologramWitherSkull extends EntityWitherSkull implements Holo
|
|||||||
if (obj instanceof EntityPlayer) {
|
if (obj instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||||
|
|
||||||
double distanceSquared = nmsPlayer.e(locX, locY, locZ);
|
double distanceSquared = GenericUtils.square(nmsPlayer.locX - this.locX) + GenericUtils.square(nmsPlayer.locZ - this.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.craftbukkit.v1_7_R2.entity.CraftEntity;
|
|||||||
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.HologramWitherSkull;
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramWitherSkull;
|
||||||
import com.gmail.filoghost.holograms.object.HologramBase;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
import com.gmail.filoghost.holograms.utils.GenericUtils;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R2.Entity;
|
import net.minecraft.server.v1_7_R2.Entity;
|
||||||
import net.minecraft.server.v1_7_R2.EntityWitherSkull;
|
import net.minecraft.server.v1_7_R2.EntityWitherSkull;
|
||||||
@ -120,7 +121,7 @@ public class EntityHologramWitherSkull extends EntityWitherSkull implements Holo
|
|||||||
if (obj instanceof EntityPlayer) {
|
if (obj instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||||
|
|
||||||
double distanceSquared = nmsPlayer.e(locX, locY, locZ);
|
double distanceSquared = GenericUtils.square(nmsPlayer.locX - this.locX) + GenericUtils.square(nmsPlayer.locZ - this.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
|
|||||||
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.HologramWitherSkull;
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramWitherSkull;
|
||||||
import com.gmail.filoghost.holograms.object.HologramBase;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
import com.gmail.filoghost.holograms.utils.GenericUtils;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R3.Entity;
|
import net.minecraft.server.v1_7_R3.Entity;
|
||||||
import net.minecraft.server.v1_7_R3.EntityPlayer;
|
import net.minecraft.server.v1_7_R3.EntityPlayer;
|
||||||
@ -124,7 +125,7 @@ public class EntityHologramWitherSkull extends EntityWitherSkull implements Holo
|
|||||||
if (obj instanceof EntityPlayer) {
|
if (obj instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||||
|
|
||||||
double distanceSquared = nmsPlayer.e(locX, locY, locZ);
|
double distanceSquared = GenericUtils.square(nmsPlayer.locX - this.locX) + GenericUtils.square(nmsPlayer.locZ - this.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
|||||||
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.HologramWitherSkull;
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramWitherSkull;
|
||||||
import com.gmail.filoghost.holograms.object.HologramBase;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
import com.gmail.filoghost.holograms.utils.GenericUtils;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R4.EntityPlayer;
|
import net.minecraft.server.v1_7_R4.EntityPlayer;
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityTeleport;
|
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityTeleport;
|
||||||
@ -124,7 +125,7 @@ public class EntityHologramWitherSkull extends EntityWitherSkull implements Holo
|
|||||||
if (obj instanceof EntityPlayer) {
|
if (obj instanceof EntityPlayer) {
|
||||||
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||||
|
|
||||||
double distanceSquared = nmsPlayer.e(locX, locY, locZ);
|
double distanceSquared = GenericUtils.square(nmsPlayer.locX - this.locX) + GenericUtils.square(nmsPlayer.locZ - this.locZ);
|
||||||
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||||
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package com.gmail.filoghost.holograms.object;
|
package com.gmail.filoghost.holograms.object;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.Configuration;
|
import com.gmail.filoghost.holograms.Configuration;
|
||||||
import com.gmail.filoghost.holograms.exception.SpawnFailedException;
|
import com.gmail.filoghost.holograms.exception.SpawnFailedException;
|
||||||
|
import com.gmail.filoghost.holograms.object.pieces.HologramLine;
|
||||||
import com.gmail.filoghost.holograms.utils.Validator;
|
import com.gmail.filoghost.holograms.utils.Validator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,12 +147,15 @@ public class CraftFloatingItem extends HologramBase implements FloatingItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void teleport(Location loc) {
|
public void teleport(Location loc) {
|
||||||
|
Validator.notNull(loc, "location cannot be null");
|
||||||
|
Validator.notNull(loc.getWorld(), "location's world cannot be null");
|
||||||
|
|
||||||
if (loc.getWorld().equals(bukkitWorld) && loc.getChunk().isLoaded() && floatingItemDoubleEntity.isSpawned()) {
|
if (loc.getWorld().equals(bukkitWorld) && loc.getChunk().isLoaded() && floatingItemDoubleEntity.isSpawned()) {
|
||||||
|
|
||||||
/* Conditions:
|
/* Conditions:
|
||||||
* - Same world
|
* - Same world
|
||||||
* - Destination chunk is loaded
|
* - Destination chunk is loaded
|
||||||
* - Entities for this floating are already spawned
|
* - Entities for this floating item are already spawned
|
||||||
*
|
*
|
||||||
* Then:
|
* Then:
|
||||||
* Send a packet near to update the position, because of this bug: https://bugs.mojang.com/browse/MC-55638
|
* Send a packet near to update the position, because of this bug: https://bugs.mojang.com/browse/MC-55638
|
||||||
@ -168,7 +171,7 @@ public class CraftFloatingItem extends HologramBase implements FloatingItem {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
boolean wasSpawned = !floatingItemDoubleEntity.isSpawned();
|
boolean wasSpawned = floatingItemDoubleEntity.isSpawned();
|
||||||
|
|
||||||
// Recreate it completely.
|
// Recreate it completely.
|
||||||
hide();
|
hide();
|
||||||
|
@ -17,6 +17,7 @@ import com.gmail.filoghost.holograms.exception.SpawnFailedException;
|
|||||||
import com.gmail.filoghost.holograms.object.pieces.FloatingDoubleEntity;
|
import com.gmail.filoghost.holograms.object.pieces.FloatingDoubleEntity;
|
||||||
import com.gmail.filoghost.holograms.object.pieces.FloatingItemDoubleEntity;
|
import com.gmail.filoghost.holograms.object.pieces.FloatingItemDoubleEntity;
|
||||||
import com.gmail.filoghost.holograms.object.pieces.FloatingTouchSlimeDoubleEntity;
|
import com.gmail.filoghost.holograms.object.pieces.FloatingTouchSlimeDoubleEntity;
|
||||||
|
import com.gmail.filoghost.holograms.object.pieces.HologramLine;
|
||||||
import com.gmail.filoghost.holograms.utils.Validator;
|
import com.gmail.filoghost.holograms.utils.Validator;
|
||||||
import com.gmail.filoghost.holograms.utils.VisibilityManager;
|
import com.gmail.filoghost.holograms.utils.VisibilityManager;
|
||||||
|
|
||||||
@ -221,6 +222,9 @@ public class CraftHologram extends HologramBase implements Hologram {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void teleport(Location loc) {
|
public void teleport(Location loc) {
|
||||||
|
Validator.notNull(loc, "location cannot be null");
|
||||||
|
Validator.notNull(loc.getWorld(), "location's world cannot be null");
|
||||||
|
|
||||||
if (loc.getWorld().equals(bukkitWorld) && loc.getChunk().isLoaded() && !linesEntities.isEmpty()) {
|
if (loc.getWorld().equals(bukkitWorld) && loc.getChunk().isLoaded() && !linesEntities.isEmpty()) {
|
||||||
|
|
||||||
/* Conditions:
|
/* Conditions:
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package com.gmail.filoghost.holograms.object;
|
package com.gmail.filoghost.holograms.object.pieces;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.exception.SpawnFailedException;
|
import com.gmail.filoghost.holograms.exception.SpawnFailedException;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.HologramHorse;
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramHorse;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.HologramWitherSkull;
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramWitherSkull;
|
||||||
import com.gmail.filoghost.holograms.object.pieces.FloatingDoubleEntity;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
import static com.gmail.filoghost.holograms.HolographicDisplays.nmsManager;
|
import static com.gmail.filoghost.holograms.HolographicDisplays.nmsManager;
|
||||||
|
|
@ -14,4 +14,8 @@ public class GenericUtils {
|
|||||||
list.add(object);
|
list.add(object);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static double square(double d) {
|
||||||
|
return d * d;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user