mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-10-18 01:15:18 +02:00
Added teleport(Location) for holograms and Floating Items, with pickup
handlers (very useful for powerups).
This commit is contained in:
parent
239fa82a8c
commit
a6d10c0a02
@ -1,6 +1,6 @@
|
|||||||
name: HolographicDisplays
|
name: HolographicDisplays
|
||||||
main: com.gmail.filoghost.holograms.HolographicDisplays
|
main: com.gmail.filoghost.holograms.HolographicDisplays
|
||||||
version: 1.8.4
|
version: 1.8.5
|
||||||
|
|
||||||
softdepend: [Multiverse-Core, MultiWorld, My Worlds, My_Worlds, ProtocolLib]
|
softdepend: [Multiverse-Core, MultiWorld, My Worlds, My_Worlds, ProtocolLib]
|
||||||
|
|
||||||
@ -9,7 +9,3 @@ commands:
|
|||||||
description: Main command for HolographicDisplays.
|
description: Main command for HolographicDisplays.
|
||||||
usage: /<command> (Startup error)
|
usage: /<command> (Startup error)
|
||||||
aliases: [hd, holo, hologram]
|
aliases: [hd, holo, hologram]
|
||||||
icon:
|
|
||||||
description: Command to create unpickable floating items.
|
|
||||||
usage: /<command> (Startup error)
|
|
||||||
aliases: [icons, floatingitem, floatingitems]
|
|
@ -169,7 +169,7 @@ public class HolographicDisplays extends JavaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProtocolLib check
|
// ProtocolLib check.
|
||||||
try {
|
try {
|
||||||
if (Bukkit.getPluginManager().isPluginEnabled("ProtocolLib")) {
|
if (Bukkit.getPluginManager().isPluginEnabled("ProtocolLib")) {
|
||||||
ProtocolLibHook.initialize();
|
ProtocolLibHook.initialize();
|
||||||
@ -179,7 +179,7 @@ public class HolographicDisplays extends JavaPlugin {
|
|||||||
logger.warning("Failed to load ProtocolLib support. Is it updated?");
|
logger.warning("Failed to load ProtocolLib support. Is it updated?");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load animation files
|
// Load animation files.
|
||||||
try {
|
try {
|
||||||
AnimationManager.loadAnimations();
|
AnimationManager.loadAnimations();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -187,7 +187,7 @@ public class HolographicDisplays extends JavaPlugin {
|
|||||||
logger.warning("Failed to load animation files!");
|
logger.warning("Failed to load animation files!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instantiate a PlaceholderManager
|
// Instantiate a PlaceholderManager.
|
||||||
placeholderManager = new PlaceholderManager();
|
placeholderManager = new PlaceholderManager();
|
||||||
|
|
||||||
// Initalize other static classes.
|
// Initalize other static classes.
|
||||||
|
@ -0,0 +1,114 @@
|
|||||||
|
package com.gmail.filoghost.holograms.api;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public interface FloatingItem {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the floating item. With floating items this method is not really needed.
|
||||||
|
* @return false if the spawn was blocked.
|
||||||
|
*/
|
||||||
|
public boolean update();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hides the floating item. To show the floating item call update().
|
||||||
|
*/
|
||||||
|
public void hide();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the current itemStack of this floating item.
|
||||||
|
*/
|
||||||
|
public void setItemStack(ItemStack itemstack);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the current itemStack of this floating item.
|
||||||
|
*/
|
||||||
|
public ItemStack getItemStack();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the location of the floating item.
|
||||||
|
*/
|
||||||
|
public Location getLocation();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the X coordinate of the floating item.
|
||||||
|
*/
|
||||||
|
public double getX();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the Y coordinate of the floating item.
|
||||||
|
*/
|
||||||
|
public double getY();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the Z coordinate of the floating item.
|
||||||
|
*/
|
||||||
|
public double getZ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the world of the floating item.
|
||||||
|
*/
|
||||||
|
public World getWorld();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Teleports the floating item to a new location, without creating new entities.
|
||||||
|
* You don't need to call update() after this.
|
||||||
|
* @param location - the new location of the floating item.
|
||||||
|
*/
|
||||||
|
public void teleport(Location location);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the touch handler of the floating item: whenever a player right clicks it, the onTouch(...)
|
||||||
|
* method of the TouchHandler is called. If null, the previous touch handler will be removed.
|
||||||
|
* @param handler - the new TouchHandler.
|
||||||
|
*/
|
||||||
|
public void setTouchHandler(ItemTouchHandler handler);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the current touch handler, null if hasTouchHandler() is false.
|
||||||
|
*/
|
||||||
|
public ItemTouchHandler getTouchHandler();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the floating item has a touch handler.
|
||||||
|
*/
|
||||||
|
public boolean hasTouchHandler();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the pickup handler of the floating item: if not null, when a player picks up the item
|
||||||
|
* the onPickup(...) method is called. If null, the previous pickup handler will be removed.
|
||||||
|
* This is very useful for powerups.
|
||||||
|
* NOTE: the floating item is NOT removed automatically and the player WON'T actually pickup the item,
|
||||||
|
* in fact the method is just called when the player is near to the floating item.
|
||||||
|
* @param handler - the new PickupHandler.
|
||||||
|
*/
|
||||||
|
public void setPickupHandler(PickupHandler handler);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the current touch handler, null if hasPickupHandler() is false.
|
||||||
|
*/
|
||||||
|
public PickupHandler getPickupHandler();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the floating item has a pickup handler.
|
||||||
|
*/
|
||||||
|
public boolean hasPickupHandler();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the timestamp of when the floating item was created, in milliseconds.
|
||||||
|
*/
|
||||||
|
public long getCreationTimestamp();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes this floating item, removing it from the lists.
|
||||||
|
*/
|
||||||
|
public void delete();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if this floating item was deleted. Calling update() on a deleted floating item will throw an exception.
|
||||||
|
*/
|
||||||
|
public boolean isDeleted();
|
||||||
|
}
|
@ -12,7 +12,7 @@ public interface Hologram {
|
|||||||
public boolean update();
|
public boolean update();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hides the hologram.
|
* Hides the hologram. To show the hologram call update().
|
||||||
*/
|
*/
|
||||||
public void hide();
|
public void hide();
|
||||||
|
|
||||||
@ -86,9 +86,17 @@ public interface Hologram {
|
|||||||
* Change the location of the hologram. You have to call update() after this method.
|
* Change the location of the hologram. You have to call update() after this method.
|
||||||
* Please note that this method will create new entities every time, so use it wisely.
|
* Please note that this method will create new entities every time, so use it wisely.
|
||||||
* @param location - the new location of the hologram.
|
* @param location - the new location of the hologram.
|
||||||
|
* @deprecated use teleport(Location location) - it's better and doesn't create new entities
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setLocation(Location location);
|
public void setLocation(Location location);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Teleports the hologram to a new location, without calling update() and with a smooth movement.
|
||||||
|
* @param location - the new location of the hologram.
|
||||||
|
*/
|
||||||
|
public void teleport(Location location);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the touch handler of the hologram: whenever a player right clicks it, the onTouch()
|
* Sets the touch handler of the hologram: whenever a player right clicks it, the onTouch()
|
||||||
* method of the TouchHandler is called. If null, the previous touch handler will be removed.
|
* method of the TouchHandler is called. If null, the previous touch handler will be removed.
|
||||||
|
@ -1,19 +1,24 @@
|
|||||||
package com.gmail.filoghost.holograms.api;
|
package com.gmail.filoghost.holograms.api;
|
||||||
|
|
||||||
|
import static com.gmail.filoghost.holograms.HolographicDisplays.nmsManager;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.NmsManager;
|
import com.gmail.filoghost.holograms.nms.interfaces.NmsManager;
|
||||||
|
import com.gmail.filoghost.holograms.object.APICraftHologram;
|
||||||
|
import com.gmail.filoghost.holograms.object.APIFloatingItemManager;
|
||||||
import com.gmail.filoghost.holograms.object.APIHologramManager;
|
import com.gmail.filoghost.holograms.object.APIHologramManager;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.CraftFloatingItem;
|
||||||
import com.gmail.filoghost.holograms.utils.GenericUtils;
|
import com.gmail.filoghost.holograms.utils.GenericUtils;
|
||||||
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;
|
||||||
import static com.gmail.filoghost.holograms.HolographicDisplays.nmsManager;
|
|
||||||
|
|
||||||
public class HolographicDisplaysAPI {
|
public class HolographicDisplaysAPI {
|
||||||
|
|
||||||
@ -30,7 +35,7 @@ public class HolographicDisplaysAPI {
|
|||||||
Validator.notNull(source, "source cannot be null");
|
Validator.notNull(source, "source cannot be null");
|
||||||
Validator.notNull(source.getWorld(), "source's world cannot be null");
|
Validator.notNull(source.getWorld(), "source's world cannot be null");
|
||||||
|
|
||||||
CraftHologram hologram = new CraftHologram("{API-Hologram}", source);
|
APICraftHologram hologram = new APICraftHologram(source);
|
||||||
APIHologramManager.addHologram(plugin, hologram);
|
APIHologramManager.addHologram(plugin, hologram);
|
||||||
|
|
||||||
if (lines != null && lines.length > 0) {
|
if (lines != null && lines.length > 0) {
|
||||||
@ -43,6 +48,28 @@ public class HolographicDisplaysAPI {
|
|||||||
return hologram;
|
return hologram;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a floating item at given location.
|
||||||
|
* @param plugin - the plugin that creates it.
|
||||||
|
* @param source - the location where it will appear.
|
||||||
|
* @param itemstack - the floating item that will appear.
|
||||||
|
* @return the new floating item created.
|
||||||
|
*/
|
||||||
|
public static FloatingItem createFloatingItem(Plugin plugin, Location source, ItemStack itemstack) {
|
||||||
|
|
||||||
|
Validator.notNull(plugin, "plugin cannot be null");
|
||||||
|
Validator.notNull(source, "source cannot be null");
|
||||||
|
Validator.notNull(source.getWorld(), "source's world cannot be null");
|
||||||
|
Validator.notNull(itemstack, "itemstack cannot be null");
|
||||||
|
Validator.checkArgument(itemstack.getType() != Material.AIR, "itemstack cannot be AIR");
|
||||||
|
|
||||||
|
CraftFloatingItem floatingItem = new CraftFloatingItem(source, itemstack);
|
||||||
|
APIFloatingItemManager.addFloatingItem(plugin, floatingItem);
|
||||||
|
|
||||||
|
floatingItem.update();
|
||||||
|
return floatingItem;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a hologram at given location that only a player can see. If the provided player is null, no one will be able to see it.
|
* Creates a hologram at given location that only a player can see. If the provided player is null, no one will be able to see it.
|
||||||
* IMPORTANT NOTE: Requires ProtocolLib.
|
* IMPORTANT NOTE: Requires ProtocolLib.
|
||||||
@ -71,7 +98,7 @@ public class HolographicDisplaysAPI {
|
|||||||
Validator.notNull(source, "source cannot be null");
|
Validator.notNull(source, "source cannot be null");
|
||||||
Validator.notNull(source.getWorld(), "source's world cannot be null");
|
Validator.notNull(source.getWorld(), "source's world cannot be null");
|
||||||
|
|
||||||
CraftHologram hologram = new CraftHologram("{API-Hologram}", source);
|
APICraftHologram hologram = new APICraftHologram(source);
|
||||||
|
|
||||||
VisibilityManager visibilityManager = new VisibilityManager();
|
VisibilityManager visibilityManager = new VisibilityManager();
|
||||||
hologram.setVisibilityManager(visibilityManager);
|
hologram.setVisibilityManager(visibilityManager);
|
||||||
@ -94,6 +121,8 @@ public class HolographicDisplaysAPI {
|
|||||||
return hologram;
|
return hologram;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO individual floating item
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a copy of all the holograms created with the API by a plugin.
|
* @return a copy of all the holograms created with the API by a plugin.
|
||||||
*/
|
*/
|
||||||
@ -102,6 +131,14 @@ public class HolographicDisplaysAPI {
|
|||||||
return APIHologramManager.getHolograms(plugin);
|
return APIHologramManager.getHolograms(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a copy of all the holograms created with the API by a plugin.
|
||||||
|
*/
|
||||||
|
public static FloatingItem[] getFloatingItems(Plugin plugin) {
|
||||||
|
Validator.notNull(plugin, "plugin cannot be null");
|
||||||
|
return APIFloatingItemManager.getFloatingItems(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return if the entity is part of a hologram.
|
* @return if the entity is part of a hologram.
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.gmail.filoghost.holograms.api;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface to handle touch floating items.
|
||||||
|
* NOTE: this doesn't handle item pickup, just right click.
|
||||||
|
*/
|
||||||
|
public interface ItemTouchHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player interacts with a floating item.
|
||||||
|
* @param floatingItem - the involved floating item
|
||||||
|
* @param player - the player who interacts
|
||||||
|
*/
|
||||||
|
public void onTouch(FloatingItem floatingItem, Player player);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.gmail.filoghost.holograms.api;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface to handle floating items being picked up by players.
|
||||||
|
*/
|
||||||
|
public interface PickupHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player picks up the floating item.
|
||||||
|
* @param floatingItem - the involved floating item
|
||||||
|
* @param player - the player who interacts
|
||||||
|
*/
|
||||||
|
public void onPickup(FloatingItem floatingItem, Player player);
|
||||||
|
|
||||||
|
}
|
@ -6,7 +6,6 @@ import java.util.List;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.commands.CommandValidator;
|
import com.gmail.filoghost.holograms.commands.CommandValidator;
|
||||||
import com.gmail.filoghost.holograms.commands.Messages;
|
import com.gmail.filoghost.holograms.commands.Messages;
|
||||||
import com.gmail.filoghost.holograms.commands.main.HologramSubCommand;
|
import com.gmail.filoghost.holograms.commands.main.HologramSubCommand;
|
||||||
|
@ -15,10 +15,12 @@ import org.bukkit.event.world.ChunkLoadEvent;
|
|||||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.Configuration;
|
import com.gmail.filoghost.holograms.Configuration;
|
||||||
|
import com.gmail.filoghost.holograms.api.FloatingItem;
|
||||||
|
import com.gmail.filoghost.holograms.api.Hologram;
|
||||||
import com.gmail.filoghost.holograms.commands.Messages;
|
import com.gmail.filoghost.holograms.commands.Messages;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.NmsManager;
|
import com.gmail.filoghost.holograms.nms.interfaces.NmsManager;
|
||||||
|
import com.gmail.filoghost.holograms.object.APIFloatingItemManager;
|
||||||
import com.gmail.filoghost.holograms.object.APIHologramManager;
|
import com.gmail.filoghost.holograms.object.APIHologramManager;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
|
||||||
import com.gmail.filoghost.holograms.object.HologramBase;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
import com.gmail.filoghost.holograms.object.HologramManager;
|
import com.gmail.filoghost.holograms.object.HologramManager;
|
||||||
|
|
||||||
@ -48,6 +50,7 @@ public class MainListener implements Listener {
|
|||||||
Chunk chunk = event.getChunk();
|
Chunk chunk = event.getChunk();
|
||||||
HologramManager.onChunkLoad(chunk);
|
HologramManager.onChunkLoad(chunk);
|
||||||
APIHologramManager.onChunkLoad(chunk);
|
APIHologramManager.onChunkLoad(chunk);
|
||||||
|
APIFloatingItemManager.onChunkLoad(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = false)
|
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = false)
|
||||||
@ -80,9 +83,19 @@ public class MainListener implements Listener {
|
|||||||
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler (priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onSlimeInteract(PlayerInteractEntityEvent event) {
|
public void onSlimeInteract(PlayerInteractEntityEvent event) {
|
||||||
if (event.getRightClicked().getType() == EntityType.SLIME) {
|
if (event.getRightClicked().getType() == EntityType.SLIME) {
|
||||||
CraftHologram hologram = nmsManager.getParentHologram(event.getRightClicked());
|
HologramBase base = nmsManager.getParentHologram(event.getRightClicked());
|
||||||
if (hologram != null && hologram.hasTouchHandler()) {
|
if (base == null) return;
|
||||||
hologram.getTouchHandler().onTouch(hologram, event.getPlayer());
|
|
||||||
|
if (base instanceof Hologram) {
|
||||||
|
Hologram textHologram = (Hologram) base;
|
||||||
|
if (textHologram.hasTouchHandler()) {
|
||||||
|
textHologram.getTouchHandler().onTouch(textHologram, event.getPlayer());
|
||||||
|
}
|
||||||
|
} else if (base instanceof FloatingItem) {
|
||||||
|
FloatingItem floatingItem = (FloatingItem) base;
|
||||||
|
if (floatingItem.hasTouchHandler()) {
|
||||||
|
floatingItem.getTouchHandler().onTouch(floatingItem, event.getPlayer());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,4 +6,6 @@ public interface CustomItem extends HologramComponent {
|
|||||||
|
|
||||||
public void setItemStackNMS(ItemStack stack);
|
public void setItemStackNMS(ItemStack stack);
|
||||||
|
|
||||||
|
public void allowPickup(boolean pickup);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package com.gmail.filoghost.holograms.nms.interfaces;
|
package com.gmail.filoghost.holograms.nms.interfaces;
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
// Represents an entity that is part of a hologram.
|
// Represents an entity that is part of a hologram.
|
||||||
public interface HologramComponent extends BasicEntityNMS {
|
public interface HologramComponent extends BasicEntityNMS {
|
||||||
|
|
||||||
// Returns the linked BaseMultiEntity. Can be null.
|
// Returns the linked HologramBase. Can be null.
|
||||||
public CraftHologram getParentHologram();
|
public HologramBase getParentHologram();
|
||||||
|
|
||||||
// Sets the linked BaseMultiEntity.
|
// Sets the linked HologramBase.
|
||||||
public void setParentHologram(CraftHologram hologram);
|
public void setParentHologram(HologramBase base);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,4 +10,6 @@ public interface HologramWitherSkull extends HologramComponent {
|
|||||||
// Sets the passenger of this entity through NMS.
|
// Sets the passenger of this entity through NMS.
|
||||||
public void setPassengerNMS(Entity bukkitEntity);
|
public void setPassengerNMS(Entity bukkitEntity);
|
||||||
|
|
||||||
|
public void sendUpdatePacketNear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package com.gmail.filoghost.holograms.nms.interfaces;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.exception.SpawnFailedException;
|
import com.gmail.filoghost.holograms.exception.SpawnFailedException;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
public interface NmsManager {
|
public interface NmsManager {
|
||||||
|
|
||||||
@ -21,8 +21,8 @@ public interface NmsManager {
|
|||||||
|
|
||||||
public boolean isBasicEntityNMS(org.bukkit.entity.Entity bukkitEntity);
|
public boolean isBasicEntityNMS(org.bukkit.entity.Entity bukkitEntity);
|
||||||
|
|
||||||
// Return null if not a hologram's part.
|
// Return null if not a hologram's (or floating item's) part.
|
||||||
public CraftHologram getParentHologram(org.bukkit.entity.Entity bukkitEntity);
|
public HologramBase getParentHologram(org.bukkit.entity.Entity bukkitEntity);
|
||||||
|
|
||||||
public FancyMessage newFancyMessage(String text);
|
public FancyMessage newFancyMessage(String text);
|
||||||
|
|
||||||
|
@ -1,24 +1,28 @@
|
|||||||
package com.gmail.filoghost.holograms.nms.v1_6_R3;
|
package com.gmail.filoghost.holograms.nms.v1_6_R3;
|
||||||
|
|
||||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
|
|
||||||
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack;
|
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.CustomItem;
|
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_6_R3.Block;
|
import net.minecraft.server.v1_6_R3.Block;
|
||||||
import net.minecraft.server.v1_6_R3.EntityItem;
|
import net.minecraft.server.v1_6_R3.EntityItem;
|
||||||
|
import net.minecraft.server.v1_6_R3.ItemStack;
|
||||||
import net.minecraft.server.v1_6_R3.NBTTagCompound;
|
import net.minecraft.server.v1_6_R3.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_6_R3.World;
|
import net.minecraft.server.v1_6_R3.World;
|
||||||
import net.minecraft.server.v1_6_R3.ItemStack;
|
import net.minecraft.server.v1_6_R3.EntityHuman;
|
||||||
|
import net.minecraft.server.v1_6_R3.EntityPlayer;
|
||||||
|
|
||||||
|
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
|
||||||
|
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.filoghost.holograms.api.FloatingItem;
|
||||||
|
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
||||||
|
import com.gmail.filoghost.holograms.nms.interfaces.CustomItem;
|
||||||
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
public class EntityCustomItem extends EntityItem implements CustomItem, BasicEntityNMS {
|
public class EntityCustomItem extends EntityItem implements CustomItem, BasicEntityNMS {
|
||||||
|
|
||||||
private static final ItemStack STONE = new ItemStack(Block.STONE, 0);
|
private static final ItemStack STONE = new ItemStack(Block.STONE, 0);
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityCustomItem(World world) {
|
public EntityCustomItem(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -40,6 +44,21 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Method called when a player is near.
|
||||||
|
@Override
|
||||||
|
public void b_(EntityHuman human) {
|
||||||
|
|
||||||
|
if (parent instanceof FloatingItem && human instanceof EntityPlayer) {
|
||||||
|
|
||||||
|
FloatingItem floatingItemParent = (FloatingItem) parent;
|
||||||
|
if (floatingItemParent.hasPickupHandler()) {
|
||||||
|
floatingItemParent.getPickupHandler().onPickup(floatingItemParent, (Player) human.getBukkitEntity());
|
||||||
|
}
|
||||||
|
|
||||||
|
// It is never added to the inventory.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
public void b(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
@ -119,13 +138,21 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void allowPickup(boolean pickup) {
|
||||||
|
if (pickup) {
|
||||||
|
super.pickupDelay = 0;
|
||||||
|
} else {
|
||||||
|
super.pickupDelay = Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@ package com.gmail.filoghost.holograms.nms.v1_6_R3;
|
|||||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.HologramHorse;
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramHorse;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
import net.minecraft.server.v1_6_R3.EntityHorse;
|
import net.minecraft.server.v1_6_R3.EntityHorse;
|
||||||
import net.minecraft.server.v1_6_R3.NBTTagCompound;
|
import net.minecraft.server.v1_6_R3.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_6_R3.World;
|
import net.minecraft.server.v1_6_R3.World;
|
||||||
@ -11,7 +12,7 @@ import net.minecraft.server.v1_6_R3.World;
|
|||||||
public class EntityHologramHorse extends EntityHorse implements HologramHorse {
|
public class EntityHologramHorse extends EntityHorse implements HologramHorse {
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityHologramHorse(World world) {
|
public EntityHologramHorse(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -138,13 +139,13 @@ public class EntityHologramHorse extends EntityHorse implements HologramHorse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,19 @@ 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.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
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;
|
||||||
import net.minecraft.server.v1_6_R3.NBTTagCompound;
|
import net.minecraft.server.v1_6_R3.NBTTagCompound;
|
||||||
|
import net.minecraft.server.v1_6_R3.Packet34EntityTeleport;
|
||||||
import net.minecraft.server.v1_6_R3.World;
|
import net.minecraft.server.v1_6_R3.World;
|
||||||
|
import net.minecraft.server.v1_6_R3.EntityPlayer;
|
||||||
|
|
||||||
public class EntityHologramWitherSkull extends EntityWitherSkull implements HologramWitherSkull {
|
public class EntityHologramWitherSkull extends EntityWitherSkull implements HologramWitherSkull {
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityHologramWitherSkull(World world) {
|
public EntityHologramWitherSkull(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -107,6 +110,24 @@ public class EntityHologramWitherSkull extends EntityWitherSkull implements Holo
|
|||||||
super.setPosition(x, y, z);
|
super.setPosition(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendUpdatePacketNear() {
|
||||||
|
|
||||||
|
// Send a packet to update the position.
|
||||||
|
Packet34EntityTeleport teleportPacket = new Packet34EntityTeleport(this);
|
||||||
|
|
||||||
|
for (Object obj : this.world.players) {
|
||||||
|
if (obj instanceof EntityPlayer) {
|
||||||
|
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||||
|
|
||||||
|
double distanceSquared = nmsPlayer.e(locX, locY, locZ);
|
||||||
|
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||||
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeadNMS() {
|
public boolean isDeadNMS() {
|
||||||
return this.dead;
|
return this.dead;
|
||||||
@ -126,13 +147,13 @@ public class EntityHologramWitherSkull extends EntityWitherSkull implements Holo
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -3,7 +3,8 @@ package com.gmail.filoghost.holograms.nms.v1_6_R3;
|
|||||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.TouchSlime;
|
import com.gmail.filoghost.holograms.nms.interfaces.TouchSlime;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
import net.minecraft.server.v1_6_R3.EntitySlime;
|
import net.minecraft.server.v1_6_R3.EntitySlime;
|
||||||
import net.minecraft.server.v1_6_R3.NBTTagCompound;
|
import net.minecraft.server.v1_6_R3.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_6_R3.World;
|
import net.minecraft.server.v1_6_R3.World;
|
||||||
@ -11,7 +12,7 @@ import net.minecraft.server.v1_6_R3.World;
|
|||||||
public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityTouchSlime(World world) {
|
public EntityTouchSlime(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -124,13 +125,13 @@ public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ 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.nms.interfaces.HologramComponent;
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramComponent;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.NmsManager;
|
import com.gmail.filoghost.holograms.nms.interfaces.NmsManager;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
import com.gmail.filoghost.holograms.utils.ReflectionUtils;
|
import com.gmail.filoghost.holograms.utils.ReflectionUtils;
|
||||||
import com.gmail.filoghost.holograms.utils.VersionUtils;
|
import com.gmail.filoghost.holograms.utils.VersionUtils;
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ public class NmsManagerImpl implements NmsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram(org.bukkit.entity.Entity bukkitEntity) {
|
public HologramBase getParentHologram(org.bukkit.entity.Entity bukkitEntity) {
|
||||||
|
|
||||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||||
if (nmsEntity instanceof HologramComponent) {
|
if (nmsEntity instanceof HologramComponent) {
|
||||||
@ -121,5 +121,4 @@ public class NmsManagerImpl implements NmsManager {
|
|||||||
public boolean hasChatHoverFeature() {
|
public boolean hasChatHoverFeature() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,23 +2,27 @@ package com.gmail.filoghost.holograms.nms.v1_7_R1;
|
|||||||
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.filoghost.holograms.api.FloatingItem;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.CustomItem;
|
import com.gmail.filoghost.holograms.nms.interfaces.CustomItem;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R1.EntityItem;
|
import net.minecraft.server.v1_7_R1.EntityItem;
|
||||||
import net.minecraft.server.v1_7_R1.ItemStack;
|
import net.minecraft.server.v1_7_R1.ItemStack;
|
||||||
import net.minecraft.server.v1_7_R1.NBTTagCompound;
|
import net.minecraft.server.v1_7_R1.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_7_R1.World;
|
import net.minecraft.server.v1_7_R1.World;
|
||||||
import net.minecraft.server.v1_7_R1.Blocks;
|
import net.minecraft.server.v1_7_R1.Blocks;
|
||||||
|
import net.minecraft.server.v1_7_R1.EntityHuman;
|
||||||
|
import net.minecraft.server.v1_7_R1.EntityPlayer;
|
||||||
|
|
||||||
public class EntityCustomItem extends EntityItem implements CustomItem, BasicEntityNMS {
|
public class EntityCustomItem extends EntityItem implements CustomItem, BasicEntityNMS {
|
||||||
|
|
||||||
private static final ItemStack STONE = new ItemStack(Blocks.STONE, 0);
|
private static final ItemStack STONE = new ItemStack(Blocks.STONE, 0);
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityCustomItem(World world) {
|
public EntityCustomItem(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -40,6 +44,21 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Method called when a player is near.
|
||||||
|
@Override
|
||||||
|
public void b_(EntityHuman human) {
|
||||||
|
|
||||||
|
if (parent instanceof FloatingItem && human instanceof EntityPlayer) {
|
||||||
|
|
||||||
|
FloatingItem floatingItemParent = (FloatingItem) parent;
|
||||||
|
if (floatingItemParent.hasPickupHandler()) {
|
||||||
|
floatingItemParent.getPickupHandler().onPickup(floatingItemParent, (Player) human.getBukkitEntity());
|
||||||
|
}
|
||||||
|
|
||||||
|
// It is never added to the inventory.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
public void b(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
@ -119,13 +138,22 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void allowPickup(boolean pickup) {
|
||||||
|
if (pickup) {
|
||||||
|
super.pickupDelay = 0;
|
||||||
|
} else {
|
||||||
|
super.pickupDelay = Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@ package com.gmail.filoghost.holograms.nms.v1_7_R1;
|
|||||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.HologramHorse;
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramHorse;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R1.EntityHorse;
|
import net.minecraft.server.v1_7_R1.EntityHorse;
|
||||||
import net.minecraft.server.v1_7_R1.NBTTagCompound;
|
import net.minecraft.server.v1_7_R1.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_7_R1.World;
|
import net.minecraft.server.v1_7_R1.World;
|
||||||
@ -11,7 +12,7 @@ import net.minecraft.server.v1_7_R1.World;
|
|||||||
public class EntityHologramHorse extends EntityHorse implements HologramHorse {
|
public class EntityHologramHorse extends EntityHorse implements HologramHorse {
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityHologramHorse(World world) {
|
public EntityHologramHorse(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -138,13 +139,12 @@ public class EntityHologramHorse extends EntityHorse implements HologramHorse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,19 @@ 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.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
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;
|
||||||
import net.minecraft.server.v1_7_R1.NBTTagCompound;
|
import net.minecraft.server.v1_7_R1.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_7_R1.World;
|
import net.minecraft.server.v1_7_R1.World;
|
||||||
|
import net.minecraft.server.v1_7_R1.EntityPlayer;
|
||||||
|
import net.minecraft.server.v1_7_R1.PacketPlayOutEntityTeleport;
|
||||||
|
|
||||||
public class EntityHologramWitherSkull extends EntityWitherSkull implements HologramWitherSkull {
|
public class EntityHologramWitherSkull extends EntityWitherSkull implements HologramWitherSkull {
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityHologramWitherSkull(World world) {
|
public EntityHologramWitherSkull(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -107,6 +110,24 @@ public class EntityHologramWitherSkull extends EntityWitherSkull implements Holo
|
|||||||
super.setPosition(x, y, z);
|
super.setPosition(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendUpdatePacketNear() {
|
||||||
|
|
||||||
|
// Send a packet to update the position.
|
||||||
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
|
for (Object obj : this.world.players) {
|
||||||
|
if (obj instanceof EntityPlayer) {
|
||||||
|
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||||
|
|
||||||
|
double distanceSquared = nmsPlayer.e(locX, locY, locZ);
|
||||||
|
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||||
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeadNMS() {
|
public boolean isDeadNMS() {
|
||||||
return this.dead;
|
return this.dead;
|
||||||
@ -125,12 +146,12 @@ public class EntityHologramWitherSkull extends EntityWitherSkull implements Holo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,7 +3,8 @@ package com.gmail.filoghost.holograms.nms.v1_7_R1;
|
|||||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.TouchSlime;
|
import com.gmail.filoghost.holograms.nms.interfaces.TouchSlime;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R1.EntitySlime;
|
import net.minecraft.server.v1_7_R1.EntitySlime;
|
||||||
import net.minecraft.server.v1_7_R1.NBTTagCompound;
|
import net.minecraft.server.v1_7_R1.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_7_R1.World;
|
import net.minecraft.server.v1_7_R1.World;
|
||||||
@ -11,7 +12,7 @@ import net.minecraft.server.v1_7_R1.World;
|
|||||||
public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityTouchSlime(World world) {
|
public EntityTouchSlime(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -124,14 +125,12 @@ public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ 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.nms.interfaces.HologramComponent;
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramComponent;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.NmsManager;
|
import com.gmail.filoghost.holograms.nms.interfaces.NmsManager;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
import com.gmail.filoghost.holograms.utils.ReflectionUtils;
|
import com.gmail.filoghost.holograms.utils.ReflectionUtils;
|
||||||
import com.gmail.filoghost.holograms.utils.VersionUtils;
|
import com.gmail.filoghost.holograms.utils.VersionUtils;
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ public class NmsManagerImpl implements NmsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram(org.bukkit.entity.Entity bukkitEntity) {
|
public HologramBase getParentHologram(org.bukkit.entity.Entity bukkitEntity) {
|
||||||
|
|
||||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||||
if (nmsEntity instanceof HologramComponent) {
|
if (nmsEntity instanceof HologramComponent) {
|
||||||
@ -120,5 +120,4 @@ public class NmsManagerImpl implements NmsManager {
|
|||||||
public boolean hasChatHoverFeature() {
|
public boolean hasChatHoverFeature() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,23 +2,27 @@ package com.gmail.filoghost.holograms.nms.v1_7_R2;
|
|||||||
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.v1_7_R2.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_7_R2.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.filoghost.holograms.api.FloatingItem;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.CustomItem;
|
import com.gmail.filoghost.holograms.nms.interfaces.CustomItem;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R2.EntityItem;
|
import net.minecraft.server.v1_7_R2.EntityItem;
|
||||||
import net.minecraft.server.v1_7_R2.ItemStack;
|
import net.minecraft.server.v1_7_R2.ItemStack;
|
||||||
import net.minecraft.server.v1_7_R2.NBTTagCompound;
|
import net.minecraft.server.v1_7_R2.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_7_R2.World;
|
import net.minecraft.server.v1_7_R2.World;
|
||||||
import net.minecraft.server.v1_7_R2.Blocks;
|
import net.minecraft.server.v1_7_R2.Blocks;
|
||||||
|
import net.minecraft.server.v1_7_R2.EntityHuman;
|
||||||
|
import net.minecraft.server.v1_7_R2.EntityPlayer;
|
||||||
|
|
||||||
public class EntityCustomItem extends EntityItem implements CustomItem, BasicEntityNMS {
|
public class EntityCustomItem extends EntityItem implements CustomItem, BasicEntityNMS {
|
||||||
|
|
||||||
private static final ItemStack STONE = new ItemStack(Blocks.STONE, 0);
|
private static final ItemStack STONE = new ItemStack(Blocks.STONE, 0);
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityCustomItem(World world) {
|
public EntityCustomItem(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -40,6 +44,21 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Method called when a player is near.
|
||||||
|
@Override
|
||||||
|
public void b_(EntityHuman human) {
|
||||||
|
|
||||||
|
if (parent instanceof FloatingItem && human instanceof EntityPlayer) {
|
||||||
|
|
||||||
|
FloatingItem floatingItemParent = (FloatingItem) parent;
|
||||||
|
if (floatingItemParent.hasPickupHandler()) {
|
||||||
|
floatingItemParent.getPickupHandler().onPickup(floatingItemParent, (Player) human.getBukkitEntity());
|
||||||
|
}
|
||||||
|
|
||||||
|
// It is never added to the inventory.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
public void b(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
@ -119,13 +138,21 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void allowPickup(boolean pickup) {
|
||||||
|
if (pickup) {
|
||||||
|
super.pickupDelay = 0;
|
||||||
|
} else {
|
||||||
|
super.pickupDelay = Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@ package com.gmail.filoghost.holograms.nms.v1_7_R2;
|
|||||||
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftEntity;
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.HologramHorse;
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramHorse;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R2.EntityHorse;
|
import net.minecraft.server.v1_7_R2.EntityHorse;
|
||||||
import net.minecraft.server.v1_7_R2.NBTTagCompound;
|
import net.minecraft.server.v1_7_R2.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_7_R2.World;
|
import net.minecraft.server.v1_7_R2.World;
|
||||||
@ -11,7 +12,7 @@ import net.minecraft.server.v1_7_R2.World;
|
|||||||
public class EntityHologramHorse extends EntityHorse implements HologramHorse {
|
public class EntityHologramHorse extends EntityHorse implements HologramHorse {
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityHologramHorse(World world) {
|
public EntityHologramHorse(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -138,13 +139,13 @@ public class EntityHologramHorse extends EntityHorse implements HologramHorse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,19 @@ 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.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
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;
|
||||||
import net.minecraft.server.v1_7_R2.NBTTagCompound;
|
import net.minecraft.server.v1_7_R2.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_7_R2.World;
|
import net.minecraft.server.v1_7_R2.World;
|
||||||
|
import net.minecraft.server.v1_7_R2.EntityPlayer;
|
||||||
|
import net.minecraft.server.v1_7_R2.PacketPlayOutEntityTeleport;
|
||||||
|
|
||||||
public class EntityHologramWitherSkull extends EntityWitherSkull implements HologramWitherSkull {
|
public class EntityHologramWitherSkull extends EntityWitherSkull implements HologramWitherSkull {
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityHologramWitherSkull(World world) {
|
public EntityHologramWitherSkull(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -107,6 +110,24 @@ public class EntityHologramWitherSkull extends EntityWitherSkull implements Holo
|
|||||||
super.setPosition(x, y, z);
|
super.setPosition(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendUpdatePacketNear() {
|
||||||
|
|
||||||
|
// Send a packet to update the position.
|
||||||
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
|
for (Object obj : this.world.players) {
|
||||||
|
if (obj instanceof EntityPlayer) {
|
||||||
|
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||||
|
|
||||||
|
double distanceSquared = nmsPlayer.e(locX, locY, locZ);
|
||||||
|
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||||
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeadNMS() {
|
public boolean isDeadNMS() {
|
||||||
return this.dead;
|
return this.dead;
|
||||||
@ -125,13 +146,13 @@ public class EntityHologramWitherSkull extends EntityWitherSkull implements Holo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -3,7 +3,8 @@ package com.gmail.filoghost.holograms.nms.v1_7_R2;
|
|||||||
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftEntity;
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.TouchSlime;
|
import com.gmail.filoghost.holograms.nms.interfaces.TouchSlime;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R2.EntitySlime;
|
import net.minecraft.server.v1_7_R2.EntitySlime;
|
||||||
import net.minecraft.server.v1_7_R2.NBTTagCompound;
|
import net.minecraft.server.v1_7_R2.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_7_R2.World;
|
import net.minecraft.server.v1_7_R2.World;
|
||||||
@ -11,7 +12,7 @@ import net.minecraft.server.v1_7_R2.World;
|
|||||||
public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityTouchSlime(World world) {
|
public EntityTouchSlime(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -124,13 +125,13 @@ public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package com.gmail.filoghost.holograms.nms.v1_7_R2;
|
package com.gmail.filoghost.holograms.nms.v1_7_R2;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_7_R2.Entity;
|
||||||
|
import net.minecraft.server.v1_7_R2.EntityTypes;
|
||||||
|
import net.minecraft.server.v1_7_R2.WorldServer;
|
||||||
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R2.CraftWorld;
|
import org.bukkit.craftbukkit.v1_7_R2.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftEntity;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
@ -9,18 +13,14 @@ import com.gmail.filoghost.holograms.exception.SpawnFailedException;
|
|||||||
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.CustomItem;
|
import com.gmail.filoghost.holograms.nms.interfaces.CustomItem;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.FancyMessage;
|
import com.gmail.filoghost.holograms.nms.interfaces.FancyMessage;
|
||||||
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramComponent;
|
||||||
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.nms.interfaces.HologramComponent;
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.NmsManager;
|
import com.gmail.filoghost.holograms.nms.interfaces.NmsManager;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
import com.gmail.filoghost.holograms.utils.ReflectionUtils;
|
import com.gmail.filoghost.holograms.utils.ReflectionUtils;
|
||||||
import com.gmail.filoghost.holograms.utils.VersionUtils;
|
import com.gmail.filoghost.holograms.utils.VersionUtils;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R2.Entity;
|
|
||||||
import net.minecraft.server.v1_7_R2.EntityTypes;
|
|
||||||
import net.minecraft.server.v1_7_R2.WorldServer;
|
|
||||||
|
|
||||||
public class NmsManagerImpl implements NmsManager {
|
public class NmsManagerImpl implements NmsManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -105,7 +105,7 @@ public class NmsManagerImpl implements NmsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram(org.bukkit.entity.Entity bukkitEntity) {
|
public HologramBase getParentHologram(org.bukkit.entity.Entity bukkitEntity) {
|
||||||
|
|
||||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||||
if (nmsEntity instanceof HologramComponent) {
|
if (nmsEntity instanceof HologramComponent) {
|
||||||
@ -124,5 +124,4 @@ public class NmsManagerImpl implements NmsManager {
|
|||||||
public boolean hasChatHoverFeature() {
|
public boolean hasChatHoverFeature() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,23 +2,27 @@ package com.gmail.filoghost.holograms.nms.v1_7_R3;
|
|||||||
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.filoghost.holograms.api.FloatingItem;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.CustomItem;
|
import com.gmail.filoghost.holograms.nms.interfaces.CustomItem;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R3.Blocks;
|
import net.minecraft.server.v1_7_R3.Blocks;
|
||||||
import net.minecraft.server.v1_7_R3.EntityItem;
|
import net.minecraft.server.v1_7_R3.EntityItem;
|
||||||
import net.minecraft.server.v1_7_R3.ItemStack;
|
import net.minecraft.server.v1_7_R3.ItemStack;
|
||||||
import net.minecraft.server.v1_7_R3.NBTTagCompound;
|
import net.minecraft.server.v1_7_R3.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_7_R3.World;
|
import net.minecraft.server.v1_7_R3.World;
|
||||||
|
import net.minecraft.server.v1_7_R3.EntityHuman;
|
||||||
|
import net.minecraft.server.v1_7_R3.EntityPlayer;
|
||||||
|
|
||||||
public class EntityCustomItem extends EntityItem implements CustomItem, BasicEntityNMS {
|
public class EntityCustomItem extends EntityItem implements CustomItem, BasicEntityNMS {
|
||||||
|
|
||||||
private static final ItemStack STONE = new ItemStack(Blocks.STONE, 0);
|
private static final ItemStack STONE = new ItemStack(Blocks.STONE, 0);
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityCustomItem(World world) {
|
public EntityCustomItem(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -40,6 +44,21 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Method called when a player is near.
|
||||||
|
@Override
|
||||||
|
public void b_(EntityHuman human) {
|
||||||
|
|
||||||
|
if (parent instanceof FloatingItem && human instanceof EntityPlayer) {
|
||||||
|
|
||||||
|
FloatingItem floatingItemParent = (FloatingItem) parent;
|
||||||
|
if (floatingItemParent.hasPickupHandler()) {
|
||||||
|
floatingItemParent.getPickupHandler().onPickup(floatingItemParent, (Player) human.getBukkitEntity());
|
||||||
|
}
|
||||||
|
|
||||||
|
// It is never added to the inventory.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
public void b(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
@ -119,13 +138,21 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void allowPickup(boolean pickup) {
|
||||||
|
if (pickup) {
|
||||||
|
super.pickupDelay = 0;
|
||||||
|
} else {
|
||||||
|
super.pickupDelay = Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@ package com.gmail.filoghost.holograms.nms.v1_7_R3;
|
|||||||
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.HologramHorse;
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramHorse;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R3.EntityHorse;
|
import net.minecraft.server.v1_7_R3.EntityHorse;
|
||||||
import net.minecraft.server.v1_7_R3.NBTTagCompound;
|
import net.minecraft.server.v1_7_R3.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_7_R3.World;
|
import net.minecraft.server.v1_7_R3.World;
|
||||||
@ -11,7 +12,7 @@ import net.minecraft.server.v1_7_R3.World;
|
|||||||
public class EntityHologramHorse extends EntityHorse implements HologramHorse {
|
public class EntityHologramHorse extends EntityHorse implements HologramHorse {
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityHologramHorse(World world) {
|
public EntityHologramHorse(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -138,13 +139,12 @@ public class EntityHologramHorse extends EntityHorse implements HologramHorse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,19 @@ 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.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
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.EntityWitherSkull;
|
import net.minecraft.server.v1_7_R3.EntityWitherSkull;
|
||||||
import net.minecraft.server.v1_7_R3.NBTTagCompound;
|
import net.minecraft.server.v1_7_R3.NBTTagCompound;
|
||||||
|
import net.minecraft.server.v1_7_R3.PacketPlayOutEntityTeleport;
|
||||||
import net.minecraft.server.v1_7_R3.World;
|
import net.minecraft.server.v1_7_R3.World;
|
||||||
|
|
||||||
public class EntityHologramWitherSkull extends EntityWitherSkull implements HologramWitherSkull {
|
public class EntityHologramWitherSkull extends EntityWitherSkull implements HologramWitherSkull {
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityHologramWitherSkull(World world) {
|
public EntityHologramWitherSkull(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -111,6 +114,24 @@ public class EntityHologramWitherSkull extends EntityWitherSkull implements Holo
|
|||||||
super.setPosition(x, y, z);
|
super.setPosition(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendUpdatePacketNear() {
|
||||||
|
|
||||||
|
// Send a packet to update the position.
|
||||||
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
|
for (Object obj : this.world.players) {
|
||||||
|
if (obj instanceof EntityPlayer) {
|
||||||
|
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||||
|
|
||||||
|
double distanceSquared = nmsPlayer.e(locX, locY, locZ);
|
||||||
|
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||||
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeadNMS() {
|
public boolean isDeadNMS() {
|
||||||
return this.dead;
|
return this.dead;
|
||||||
@ -129,13 +150,12 @@ public class EntityHologramWitherSkull extends EntityWitherSkull implements Holo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -3,7 +3,6 @@ package com.gmail.filoghost.holograms.nms.v1_7_R3;
|
|||||||
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.TouchSlime;
|
import com.gmail.filoghost.holograms.nms.interfaces.TouchSlime;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
|
||||||
import com.gmail.filoghost.holograms.object.HologramBase;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R3.EntitySlime;
|
import net.minecraft.server.v1_7_R3.EntitySlime;
|
||||||
@ -13,7 +12,7 @@ import net.minecraft.server.v1_7_R3.World;
|
|||||||
public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityTouchSlime(World world) {
|
public EntityTouchSlime(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -91,10 +90,12 @@ public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
|||||||
// Remove sounds.
|
// Remove sounds.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setLockTick(boolean lock) {
|
public void setLockTick(boolean lock) {
|
||||||
lockTick = lock;
|
lockTick = lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void die() {
|
public void die() {
|
||||||
setLockTick(false);
|
setLockTick(false);
|
||||||
super.die();
|
super.die();
|
||||||
@ -104,6 +105,7 @@ public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
|||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
if (super.bukkitEntity == null) {
|
if (super.bukkitEntity == null) {
|
||||||
this.bukkitEntity = new CraftTouchSlime(this.world.getServer(), this);
|
this.bukkitEntity = new CraftTouchSlime(this.world.getServer(), this);
|
||||||
@ -127,13 +129,12 @@ public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package com.gmail.filoghost.holograms.nms.v1_7_R3;
|
package com.gmail.filoghost.holograms.nms.v1_7_R3;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_7_R3.Entity;
|
||||||
|
import net.minecraft.server.v1_7_R3.EntityTypes;
|
||||||
|
import net.minecraft.server.v1_7_R3.WorldServer;
|
||||||
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R3.CraftWorld;
|
import org.bukkit.craftbukkit.v1_7_R3.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
@ -9,18 +13,14 @@ import com.gmail.filoghost.holograms.exception.SpawnFailedException;
|
|||||||
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.CustomItem;
|
import com.gmail.filoghost.holograms.nms.interfaces.CustomItem;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.FancyMessage;
|
import com.gmail.filoghost.holograms.nms.interfaces.FancyMessage;
|
||||||
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramComponent;
|
||||||
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.nms.interfaces.HologramComponent;
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.NmsManager;
|
import com.gmail.filoghost.holograms.nms.interfaces.NmsManager;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
import com.gmail.filoghost.holograms.utils.ReflectionUtils;
|
import com.gmail.filoghost.holograms.utils.ReflectionUtils;
|
||||||
import com.gmail.filoghost.holograms.utils.VersionUtils;
|
import com.gmail.filoghost.holograms.utils.VersionUtils;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R3.Entity;
|
|
||||||
import net.minecraft.server.v1_7_R3.EntityTypes;
|
|
||||||
import net.minecraft.server.v1_7_R3.WorldServer;
|
|
||||||
|
|
||||||
public class NmsManagerImpl implements NmsManager {
|
public class NmsManagerImpl implements NmsManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -105,7 +105,7 @@ public class NmsManagerImpl implements NmsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram(org.bukkit.entity.Entity bukkitEntity) {
|
public HologramBase getParentHologram(org.bukkit.entity.Entity bukkitEntity) {
|
||||||
|
|
||||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||||
if (nmsEntity instanceof HologramComponent) {
|
if (nmsEntity instanceof HologramComponent) {
|
||||||
@ -124,5 +124,4 @@ public class NmsManagerImpl implements NmsManager {
|
|||||||
public boolean hasChatHoverFeature() {
|
public boolean hasChatHoverFeature() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,28 @@
|
|||||||
package com.gmail.filoghost.holograms.nms.v1_7_R4;
|
package com.gmail.filoghost.holograms.nms.v1_7_R4;
|
||||||
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.CustomItem;
|
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R4.Blocks;
|
import net.minecraft.server.v1_7_R4.Blocks;
|
||||||
|
import net.minecraft.server.v1_7_R4.EntityHuman;
|
||||||
import net.minecraft.server.v1_7_R4.EntityItem;
|
import net.minecraft.server.v1_7_R4.EntityItem;
|
||||||
|
import net.minecraft.server.v1_7_R4.EntityPlayer;
|
||||||
import net.minecraft.server.v1_7_R4.ItemStack;
|
import net.minecraft.server.v1_7_R4.ItemStack;
|
||||||
import net.minecraft.server.v1_7_R4.NBTTagCompound;
|
import net.minecraft.server.v1_7_R4.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_7_R4.World;
|
import net.minecraft.server.v1_7_R4.World;
|
||||||
|
|
||||||
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||||
|
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.filoghost.holograms.api.FloatingItem;
|
||||||
|
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
||||||
|
import com.gmail.filoghost.holograms.nms.interfaces.CustomItem;
|
||||||
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
public class EntityCustomItem extends EntityItem implements CustomItem, BasicEntityNMS {
|
public class EntityCustomItem extends EntityItem implements CustomItem, BasicEntityNMS {
|
||||||
|
|
||||||
private static final ItemStack STONE = new ItemStack(Blocks.STONE, 0);
|
private static final ItemStack STONE = new ItemStack(Blocks.STONE, 0);
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityCustomItem(World world) {
|
public EntityCustomItem(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -40,6 +44,21 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Method called when a player is near.
|
||||||
|
@Override
|
||||||
|
public void b_(EntityHuman human) {
|
||||||
|
|
||||||
|
if (parent instanceof FloatingItem && human instanceof EntityPlayer) {
|
||||||
|
|
||||||
|
FloatingItem floatingItemParent = (FloatingItem) parent;
|
||||||
|
if (floatingItemParent.hasPickupHandler()) {
|
||||||
|
floatingItemParent.getPickupHandler().onPickup(floatingItemParent, (Player) human.getBukkitEntity());
|
||||||
|
}
|
||||||
|
|
||||||
|
// It is never added to the inventory.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
public void b(NBTTagCompound nbttagcompound) {
|
||||||
// Do not save NBT.
|
// Do not save NBT.
|
||||||
@ -118,14 +137,24 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt
|
|||||||
setItemStack(newItem);
|
setItemStack(newItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void allowPickup(boolean pickup) {
|
||||||
|
if (pickup) {
|
||||||
|
super.pickupDelay = 0;
|
||||||
|
} else {
|
||||||
|
super.pickupDelay = Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@ package com.gmail.filoghost.holograms.nms.v1_7_R4;
|
|||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.HologramHorse;
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramHorse;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R4.EntityHorse;
|
import net.minecraft.server.v1_7_R4.EntityHorse;
|
||||||
import net.minecraft.server.v1_7_R4.NBTTagCompound;
|
import net.minecraft.server.v1_7_R4.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_7_R4.World;
|
import net.minecraft.server.v1_7_R4.World;
|
||||||
@ -11,7 +12,7 @@ import net.minecraft.server.v1_7_R4.World;
|
|||||||
public class EntityHologramHorse extends EntityHorse implements HologramHorse {
|
public class EntityHologramHorse extends EntityHorse implements HologramHorse {
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityHologramHorse(World world) {
|
public EntityHologramHorse(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -138,13 +139,12 @@ public class EntityHologramHorse extends EntityHorse implements HologramHorse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,10 @@ 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.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_7_R4.EntityPlayer;
|
||||||
|
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityTeleport;
|
||||||
import net.minecraft.server.v1_7_R4.Entity;
|
import net.minecraft.server.v1_7_R4.Entity;
|
||||||
import net.minecraft.server.v1_7_R4.EntityWitherSkull;
|
import net.minecraft.server.v1_7_R4.EntityWitherSkull;
|
||||||
import net.minecraft.server.v1_7_R4.NBTTagCompound;
|
import net.minecraft.server.v1_7_R4.NBTTagCompound;
|
||||||
@ -13,7 +16,7 @@ import net.minecraft.server.v1_7_R4.World;
|
|||||||
public class EntityHologramWitherSkull extends EntityWitherSkull implements HologramWitherSkull {
|
public class EntityHologramWitherSkull extends EntityWitherSkull implements HologramWitherSkull {
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityHologramWitherSkull(World world) {
|
public EntityHologramWitherSkull(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -111,6 +114,24 @@ public class EntityHologramWitherSkull extends EntityWitherSkull implements Holo
|
|||||||
super.setPosition(x, y, z);
|
super.setPosition(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendUpdatePacketNear() {
|
||||||
|
|
||||||
|
// Send a packet to update the position.
|
||||||
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(this);
|
||||||
|
|
||||||
|
for (Object obj : this.world.players) {
|
||||||
|
if (obj instanceof EntityPlayer) {
|
||||||
|
EntityPlayer nmsPlayer = (EntityPlayer) obj;
|
||||||
|
|
||||||
|
double distanceSquared = nmsPlayer.e(locX, locY, locZ);
|
||||||
|
if (distanceSquared < 8192 && nmsPlayer.playerConnection != null) {
|
||||||
|
nmsPlayer.playerConnection.sendPacket(teleportPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDeadNMS() {
|
public boolean isDeadNMS() {
|
||||||
return this.dead;
|
return this.dead;
|
||||||
@ -129,13 +150,12 @@ public class EntityHologramWitherSkull extends EntityWitherSkull implements Holo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -3,7 +3,6 @@ package com.gmail.filoghost.holograms.nms.v1_7_R4;
|
|||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.TouchSlime;
|
import com.gmail.filoghost.holograms.nms.interfaces.TouchSlime;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
|
||||||
import com.gmail.filoghost.holograms.object.HologramBase;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R4.EntitySlime;
|
import net.minecraft.server.v1_7_R4.EntitySlime;
|
||||||
@ -13,7 +12,7 @@ import net.minecraft.server.v1_7_R4.World;
|
|||||||
public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private CraftHologram parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
public EntityTouchSlime(World world) {
|
public EntityTouchSlime(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -91,10 +90,12 @@ public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
|||||||
// Remove sounds.
|
// Remove sounds.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setLockTick(boolean lock) {
|
public void setLockTick(boolean lock) {
|
||||||
lockTick = lock;
|
lockTick = lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void die() {
|
public void die() {
|
||||||
setLockTick(false);
|
setLockTick(false);
|
||||||
super.die();
|
super.die();
|
||||||
@ -104,6 +105,7 @@ public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
|||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
if (super.bukkitEntity == null) {
|
if (super.bukkitEntity == null) {
|
||||||
this.bukkitEntity = new CraftTouchSlime(this.world.getServer(), this);
|
this.bukkitEntity = new CraftTouchSlime(this.world.getServer(), this);
|
||||||
@ -127,13 +129,13 @@ public class EntityTouchSlime extends EntitySlime implements TouchSlime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram() {
|
public HologramBase getParentHologram() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParentHologram(CraftHologram hologram) {
|
public void setParentHologram(HologramBase base) {
|
||||||
this.parent = hologram;
|
this.parent = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package com.gmail.filoghost.holograms.nms.v1_7_R4;
|
package com.gmail.filoghost.holograms.nms.v1_7_R4;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_7_R4.Entity;
|
||||||
|
import net.minecraft.server.v1_7_R4.EntityTypes;
|
||||||
|
import net.minecraft.server.v1_7_R4.WorldServer;
|
||||||
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
@ -9,18 +13,14 @@ import com.gmail.filoghost.holograms.exception.SpawnFailedException;
|
|||||||
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.CustomItem;
|
import com.gmail.filoghost.holograms.nms.interfaces.CustomItem;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.FancyMessage;
|
import com.gmail.filoghost.holograms.nms.interfaces.FancyMessage;
|
||||||
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramComponent;
|
||||||
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.nms.interfaces.HologramComponent;
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.NmsManager;
|
import com.gmail.filoghost.holograms.nms.interfaces.NmsManager;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
import com.gmail.filoghost.holograms.utils.ReflectionUtils;
|
import com.gmail.filoghost.holograms.utils.ReflectionUtils;
|
||||||
import com.gmail.filoghost.holograms.utils.VersionUtils;
|
import com.gmail.filoghost.holograms.utils.VersionUtils;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R4.Entity;
|
|
||||||
import net.minecraft.server.v1_7_R4.EntityTypes;
|
|
||||||
import net.minecraft.server.v1_7_R4.WorldServer;
|
|
||||||
|
|
||||||
public class NmsManagerImpl implements NmsManager {
|
public class NmsManagerImpl implements NmsManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -105,7 +105,7 @@ public class NmsManagerImpl implements NmsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftHologram getParentHologram(org.bukkit.entity.Entity bukkitEntity) {
|
public HologramBase getParentHologram(org.bukkit.entity.Entity bukkitEntity) {
|
||||||
|
|
||||||
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
|
||||||
if (nmsEntity instanceof HologramComponent) {
|
if (nmsEntity instanceof HologramComponent) {
|
||||||
@ -124,5 +124,4 @@ public class NmsManagerImpl implements NmsManager {
|
|||||||
public boolean hasChatHoverFeature() {
|
public boolean hasChatHoverFeature() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.gmail.filoghost.holograms.object;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import com.gmail.filoghost.holograms.Configuration;
|
||||||
|
import com.gmail.filoghost.holograms.exception.SpawnFailedException;
|
||||||
|
import com.gmail.filoghost.holograms.utils.Validator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exactly like CraftHologram, but without variable replacement (more clean).
|
||||||
|
*/
|
||||||
|
public class APICraftHologram extends CraftHologram {
|
||||||
|
|
||||||
|
public APICraftHologram(Location source) {
|
||||||
|
super("{API-Hologram}", source);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Just changes this method.
|
||||||
|
@Override
|
||||||
|
public boolean forceUpdate() {
|
||||||
|
|
||||||
|
Validator.checkState(!isDeleted(), "Hologram already deleted");
|
||||||
|
|
||||||
|
// Remove previous entities.
|
||||||
|
hide();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
double lineSpacing = Configuration.verticalLineSpacing;
|
||||||
|
|
||||||
|
// While iterating we change this var.
|
||||||
|
double currentY = this.y;
|
||||||
|
|
||||||
|
for (String text : textLines) {
|
||||||
|
|
||||||
|
HologramLine lineEntity = new HologramLine(text);
|
||||||
|
lineEntity.spawn(this, bukkitWorld, x, currentY, z);
|
||||||
|
linesEntities.add(lineEntity);
|
||||||
|
|
||||||
|
currentY -= lineSpacing;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (touchHandler != null) {
|
||||||
|
touchSlimeEntity.spawn(this, bukkitWorld, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SpawnFailedException ex) {
|
||||||
|
// Kill the entities and return false.
|
||||||
|
hide();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
package com.gmail.filoghost.holograms.object;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import com.gmail.filoghost.holograms.api.FloatingItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is only used by the plugin itself. Other plugins should just use the API.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class APIFloatingItemManager {
|
||||||
|
|
||||||
|
private static Map<Plugin, List<CraftFloatingItem>> apiFloatingItems = new HashMap<Plugin, List<CraftFloatingItem>>();
|
||||||
|
|
||||||
|
public static void onChunkLoad(Chunk chunk) {
|
||||||
|
for (List<CraftFloatingItem> pluginFloatingItemList : apiFloatingItems.values()) {
|
||||||
|
for (CraftFloatingItem floatingItem : pluginFloatingItemList) {
|
||||||
|
if (floatingItem.isInChunk(chunk)) {
|
||||||
|
floatingItem.forceUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onChunkUnload(Chunk chunk) {
|
||||||
|
for (List<CraftFloatingItem> pluginFloatingItemList : apiFloatingItems.values()) {
|
||||||
|
for (CraftFloatingItem floatingItem : pluginFloatingItemList) {
|
||||||
|
if (floatingItem.isInChunk(chunk)) {
|
||||||
|
floatingItem.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addFloatingItem(Plugin plugin, CraftFloatingItem floatingItem) {
|
||||||
|
List<CraftFloatingItem> pluginFloatingItemList = apiFloatingItems.get(plugin);
|
||||||
|
if (pluginFloatingItemList == null) {
|
||||||
|
pluginFloatingItemList = new ArrayList<CraftFloatingItem>();
|
||||||
|
apiFloatingItems.put(plugin, pluginFloatingItemList);
|
||||||
|
}
|
||||||
|
pluginFloatingItemList.add(floatingItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void remove(FloatingItem floatingItem) {
|
||||||
|
for (List<CraftFloatingItem> pluginFloatingItemList : apiFloatingItems.values()) {
|
||||||
|
pluginFloatingItemList.remove(floatingItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FloatingItem[] getFloatingItems(Plugin plugin) {
|
||||||
|
List<CraftFloatingItem> pluginFloatingItemList = apiFloatingItems.get(plugin);
|
||||||
|
if (pluginFloatingItemList == null) {
|
||||||
|
return new FloatingItem[0];
|
||||||
|
} else {
|
||||||
|
return pluginFloatingItemList.toArray(new FloatingItem[pluginFloatingItemList.size()]);
|
||||||
|
// It's a copy of the original list. Floating items should be removed with delete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -59,7 +59,7 @@ public class APIHologramManager {
|
|||||||
return new Hologram[0];
|
return new Hologram[0];
|
||||||
} else {
|
} else {
|
||||||
return pluginHologramList.toArray(new Hologram[pluginHologramList.size()]);
|
return pluginHologramList.toArray(new Hologram[pluginHologramList.size()]);
|
||||||
// It's a copy of the original list. Holograms should be removed with hologram.delete()
|
// It's a copy of the original list. Holograms should be removed with delete()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,194 @@
|
|||||||
|
package com.gmail.filoghost.holograms.object;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.gmail.filoghost.holograms.api.FloatingItem;
|
||||||
|
import com.gmail.filoghost.holograms.api.ItemTouchHandler;
|
||||||
|
import com.gmail.filoghost.holograms.api.PickupHandler;
|
||||||
|
import com.gmail.filoghost.holograms.exception.SpawnFailedException;
|
||||||
|
import com.gmail.filoghost.holograms.object.pieces.FloatingItemDoubleEntity;
|
||||||
|
import com.gmail.filoghost.holograms.object.pieces.FloatingTouchSlimeDoubleEntity;
|
||||||
|
import com.gmail.filoghost.holograms.utils.Validator;
|
||||||
|
import com.gmail.filoghost.holograms.utils.VisibilityManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is only used by the plugin itself. Other plugins should just use the API.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CraftFloatingItem extends HologramBase implements FloatingItem {
|
||||||
|
|
||||||
|
protected FloatingItemDoubleEntity floatingItemDoubleEntity;
|
||||||
|
protected VisibilityManager visibilityManager;
|
||||||
|
|
||||||
|
protected long creationTimestamp;
|
||||||
|
|
||||||
|
protected FloatingTouchSlimeDoubleEntity touchSlimeEntity;
|
||||||
|
protected ItemTouchHandler touchHandler;
|
||||||
|
protected PickupHandler pickupHandler;
|
||||||
|
|
||||||
|
public CraftFloatingItem(Location source, ItemStack itemStack) {
|
||||||
|
super("{API-FloatingItem}", source);
|
||||||
|
floatingItemDoubleEntity = new FloatingItemDoubleEntity(itemStack);
|
||||||
|
touchSlimeEntity = new FloatingTouchSlimeDoubleEntity();
|
||||||
|
creationTimestamp = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getCreationTimestamp() {
|
||||||
|
return creationTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVisibilityManager(VisibilityManager visibilityManager) {
|
||||||
|
this.visibilityManager = visibilityManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasVisibilityManager() {
|
||||||
|
return visibilityManager != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VisibilityManager getVisibilityManager() {
|
||||||
|
return visibilityManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTouchHandler(ItemTouchHandler touchHandler) {
|
||||||
|
this.touchHandler = touchHandler;
|
||||||
|
|
||||||
|
if (touchHandler != null && !touchSlimeEntity.isSpawned()) {
|
||||||
|
try {
|
||||||
|
touchSlimeEntity.spawn(this, bukkitWorld, x, y, z);
|
||||||
|
} catch (SpawnFailedException e) { }
|
||||||
|
} else if (touchHandler == null && touchSlimeEntity.isSpawned()) {
|
||||||
|
touchSlimeEntity.despawn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasTouchHandler() {
|
||||||
|
return touchHandler != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemTouchHandler getTouchHandler() {
|
||||||
|
return touchHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPickupHandler(PickupHandler handler) {
|
||||||
|
this.pickupHandler = handler;
|
||||||
|
|
||||||
|
// Allow the item to be pickup up only if there's a PickupHandler.
|
||||||
|
floatingItemDoubleEntity.setAllowPickup(hasPickupHandler());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PickupHandler getPickupHandler() {
|
||||||
|
return pickupHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPickupHandler() {
|
||||||
|
return pickupHandler != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update() {
|
||||||
|
if (isInLoadedChunk()) {
|
||||||
|
return forceUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the hologram without checking if it's in a loaded chunk.
|
||||||
|
*/
|
||||||
|
public boolean forceUpdate() {
|
||||||
|
|
||||||
|
Validator.checkState(!isDeleted(), "Floating item already deleted");
|
||||||
|
|
||||||
|
// Remove previous entities.
|
||||||
|
hide();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
floatingItemDoubleEntity.spawn(this, bukkitWorld, x, y, z);
|
||||||
|
|
||||||
|
} catch (SpawnFailedException ex) {
|
||||||
|
// Kill the entities and return false.
|
||||||
|
hide();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
floatingItemDoubleEntity.despawn();
|
||||||
|
|
||||||
|
if (touchSlimeEntity.isSpawned()) {
|
||||||
|
touchSlimeEntity.despawn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDeleteEvent() {
|
||||||
|
hide();
|
||||||
|
APIFloatingItemManager.remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CraftFloatingItem{itemstack=" + floatingItemDoubleEntity.getItemStack().toString() + ",x=" + x + ",y=" + y + ",z=" + z + ",world=" + bukkitWorld.getName() + "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void teleport(Location loc) {
|
||||||
|
if (loc.getWorld().equals(bukkitWorld) && loc.getChunk().isLoaded() && floatingItemDoubleEntity.isSpawned()) {
|
||||||
|
|
||||||
|
/* Conditions:
|
||||||
|
* - Same world
|
||||||
|
* - Destination chunk is loaded
|
||||||
|
* - Entities for this floating are already spawned
|
||||||
|
*
|
||||||
|
* Then:
|
||||||
|
* Send a packet near to update the position, because of this bug: https://bugs.mojang.com/browse/MC-55638
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
floatingItemDoubleEntity.teleport(loc.getX(), loc.getY(), loc.getZ());
|
||||||
|
|
||||||
|
if (touchSlimeEntity.isSpawned()) {
|
||||||
|
touchSlimeEntity.teleport(loc.getX(), loc.getY(), loc.getZ());
|
||||||
|
}
|
||||||
|
setLocation(loc);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
boolean wasSpawned = !floatingItemDoubleEntity.isSpawned();
|
||||||
|
|
||||||
|
// Recreate it completely.
|
||||||
|
hide();
|
||||||
|
setLocation(loc);
|
||||||
|
|
||||||
|
if (wasSpawned) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setItemStack(ItemStack itemstack) {
|
||||||
|
Validator.notNull(itemstack, "itemStack cannot be null");
|
||||||
|
Validator.checkArgument(itemstack.getType() != Material.AIR, "itemStack cannot be AIR");
|
||||||
|
floatingItemDoubleEntity.setItemStack(itemstack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getItemStack() {
|
||||||
|
return floatingItemDoubleEntity.getItemStack();
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,9 @@ import com.gmail.filoghost.holograms.api.TouchHandler;
|
|||||||
import com.gmail.filoghost.holograms.commands.CommandValidator;
|
import com.gmail.filoghost.holograms.commands.CommandValidator;
|
||||||
import com.gmail.filoghost.holograms.exception.CommandException;
|
import com.gmail.filoghost.holograms.exception.CommandException;
|
||||||
import com.gmail.filoghost.holograms.exception.SpawnFailedException;
|
import com.gmail.filoghost.holograms.exception.SpawnFailedException;
|
||||||
|
import com.gmail.filoghost.holograms.object.pieces.FloatingDoubleEntity;
|
||||||
|
import com.gmail.filoghost.holograms.object.pieces.FloatingItemDoubleEntity;
|
||||||
|
import com.gmail.filoghost.holograms.object.pieces.FloatingTouchSlimeDoubleEntity;
|
||||||
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;
|
||||||
|
|
||||||
@ -23,21 +26,21 @@ import com.gmail.filoghost.holograms.utils.VisibilityManager;
|
|||||||
|
|
||||||
public class CraftHologram extends HologramBase implements Hologram {
|
public class CraftHologram extends HologramBase implements Hologram {
|
||||||
|
|
||||||
private List<FloatingDoubleEntity> linesEntities;
|
protected List<FloatingDoubleEntity> linesEntities;
|
||||||
private List<String> textLines;
|
protected List<String> textLines;
|
||||||
|
|
||||||
private VisibilityManager visibilityManager;
|
protected VisibilityManager visibilityManager;
|
||||||
|
|
||||||
private long creationTimestamp;
|
protected long creationTimestamp;
|
||||||
|
|
||||||
private FloatingTouchSlime touchSlimeEntity;
|
protected FloatingTouchSlimeDoubleEntity touchSlimeEntity;
|
||||||
private TouchHandler touchHandler;
|
protected TouchHandler touchHandler;
|
||||||
|
|
||||||
public CraftHologram(String name, Location source) {
|
public CraftHologram(String name, Location source) {
|
||||||
super(name, source);
|
super(name, source);
|
||||||
linesEntities = new ArrayList<FloatingDoubleEntity>();
|
linesEntities = new ArrayList<FloatingDoubleEntity>();
|
||||||
textLines = new ArrayList<String>();
|
textLines = new ArrayList<String>();
|
||||||
touchSlimeEntity = new FloatingTouchSlime();
|
touchSlimeEntity = new FloatingTouchSlimeDoubleEntity();
|
||||||
creationTimestamp = System.currentTimeMillis();
|
creationTimestamp = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +164,7 @@ public class CraftHologram extends HologramBase implements Hologram {
|
|||||||
currentY -= 0.27;
|
currentY -= 0.27;
|
||||||
}
|
}
|
||||||
|
|
||||||
FloatingItem lineEntity = new FloatingItem(icon);
|
FloatingItemDoubleEntity lineEntity = new FloatingItemDoubleEntity(icon);
|
||||||
lineEntity.spawn(this, bukkitWorld, x, currentY, z);
|
lineEntity.spawn(this, bukkitWorld, x, currentY, z);
|
||||||
linesEntities.add(lineEntity);
|
linesEntities.add(lineEntity);
|
||||||
|
|
||||||
@ -215,4 +218,60 @@ public class CraftHologram extends HologramBase implements Hologram {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "CraftHologram{lines=" + textLines.toString() + ",x=" + x + ",y=" + y + ",z=" + z + ",world=" + bukkitWorld.getName() + "}";
|
return "CraftHologram{lines=" + textLines.toString() + ",x=" + x + ",y=" + y + ",z=" + z + ",world=" + bukkitWorld.getName() + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void teleport(Location loc) {
|
||||||
|
if (loc.getWorld().equals(bukkitWorld) && loc.getChunk().isLoaded() && !linesEntities.isEmpty()) {
|
||||||
|
|
||||||
|
/* Conditions:
|
||||||
|
* - Same world
|
||||||
|
* - Destination chunk is loaded
|
||||||
|
* - Entities for this hologram are already spawned
|
||||||
|
*
|
||||||
|
* Then:
|
||||||
|
* Send a packet near to update the position, because of this bug: https://bugs.mojang.com/browse/MC-55638
|
||||||
|
*/
|
||||||
|
|
||||||
|
double lineSpacing = Configuration.verticalLineSpacing;
|
||||||
|
|
||||||
|
// While iterating we change this var.
|
||||||
|
double currentY = loc.getY();
|
||||||
|
|
||||||
|
for (FloatingDoubleEntity lineEntity : linesEntities) {
|
||||||
|
|
||||||
|
if (lineEntity instanceof FloatingItemDoubleEntity) {
|
||||||
|
|
||||||
|
if (currentY != loc.getY()) {
|
||||||
|
// Extra space for the floating item...
|
||||||
|
currentY -= 0.27;
|
||||||
|
}
|
||||||
|
|
||||||
|
lineEntity.teleport(loc.getX(), currentY, loc.getZ());
|
||||||
|
currentY -= 0.05;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
lineEntity.teleport(loc.getX(), currentY, loc.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
currentY -= lineSpacing;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (touchSlimeEntity.isSpawned()) {
|
||||||
|
touchSlimeEntity.teleport(loc.getX(), loc.getY(), loc.getZ());
|
||||||
|
}
|
||||||
|
setLocation(loc);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
boolean wasSpawned = !linesEntities.isEmpty();
|
||||||
|
|
||||||
|
// Recreate it completely.
|
||||||
|
hide();
|
||||||
|
setLocation(loc);
|
||||||
|
|
||||||
|
if (wasSpawned) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
package com.gmail.filoghost.holograms.object;
|
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.exception.SpawnFailedException;
|
|
||||||
|
|
||||||
// Represents an object associated with a hologram, made of a wither skull with a passenger.
|
|
||||||
public abstract class FloatingDoubleEntity {
|
|
||||||
|
|
||||||
public abstract void spawn(CraftHologram parent, World bukkitWorld, double x, double y, double z) throws SpawnFailedException;
|
|
||||||
|
|
||||||
public abstract void despawn();
|
|
||||||
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
package com.gmail.filoghost.holograms.object;
|
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import com.gmail.filoghost.holograms.exception.SpawnFailedException;
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.CustomItem;
|
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.HologramWitherSkull;
|
|
||||||
import static com.gmail.filoghost.holograms.HolographicDisplays.nmsManager;
|
|
||||||
|
|
||||||
public class FloatingItem extends FloatingDoubleEntity {
|
|
||||||
|
|
||||||
private static final double VERTICAL_OFFSET = -0.21;
|
|
||||||
|
|
||||||
private ItemStack itemStack;
|
|
||||||
private CustomItem item;
|
|
||||||
private HologramWitherSkull skull;
|
|
||||||
|
|
||||||
public FloatingItem(ItemStack itemStack) {
|
|
||||||
this.itemStack = itemStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void spawn(CraftHologram parent, World bukkitWorld, double x, double y, double z) throws SpawnFailedException {
|
|
||||||
despawn();
|
|
||||||
|
|
||||||
item = nmsManager.spawnCustomItem(bukkitWorld, x, y + VERTICAL_OFFSET, z, itemStack);
|
|
||||||
item.setParentHologram(parent);
|
|
||||||
|
|
||||||
skull = nmsManager.spawnHologramWitherSkull(bukkitWorld, x, y + VERTICAL_OFFSET, z);
|
|
||||||
skull.setParentHologram(parent);
|
|
||||||
|
|
||||||
// Let the item ride the wither skull.
|
|
||||||
skull.setPassengerNMS(item);
|
|
||||||
|
|
||||||
item.setLockTick(true);
|
|
||||||
skull.setLockTick(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void despawn() {
|
|
||||||
if (item != null) {
|
|
||||||
item.killEntityNMS();
|
|
||||||
item = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skull != null) {
|
|
||||||
skull.killEntityNMS();
|
|
||||||
skull = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -90,12 +90,6 @@ public abstract class HologramBase {
|
|||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void onDeleteEvent();
|
|
||||||
|
|
||||||
public abstract boolean update();
|
|
||||||
|
|
||||||
public abstract void hide();
|
|
||||||
|
|
||||||
public final void setLocation(Location source) {
|
public final void setLocation(Location source) {
|
||||||
Validator.notNull(source, "location cannot be null");
|
Validator.notNull(source, "location cannot be null");
|
||||||
Validator.notNull(source.getWorld(), "location's world cannot be null");
|
Validator.notNull(source.getWorld(), "location's world cannot be null");
|
||||||
@ -108,4 +102,10 @@ public abstract class HologramBase {
|
|||||||
chunkZ = source.getChunk().getZ();
|
chunkZ = source.getChunk().getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void onDeleteEvent();
|
||||||
|
|
||||||
|
public abstract boolean update();
|
||||||
|
|
||||||
|
public abstract void hide();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ 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 static com.gmail.filoghost.holograms.HolographicDisplays.nmsManager;
|
import static com.gmail.filoghost.holograms.HolographicDisplays.nmsManager;
|
||||||
|
|
||||||
public class HologramLine extends FloatingDoubleEntity {
|
public class HologramLine extends FloatingDoubleEntity {
|
||||||
@ -24,7 +26,7 @@ public class HologramLine extends FloatingDoubleEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(CraftHologram parent, World bukkitWorld, double x, double y, double z) throws SpawnFailedException {
|
public void spawn(HologramBase parent, World bukkitWorld, double x, double y, double z) throws SpawnFailedException {
|
||||||
despawn();
|
despawn();
|
||||||
|
|
||||||
horse = nmsManager.spawnHologramHorse(bukkitWorld, x, y + VERTICAL_OFFSET, z);
|
horse = nmsManager.spawnHologramHorse(bukkitWorld, x, y + VERTICAL_OFFSET, z);
|
||||||
@ -56,4 +58,12 @@ public class HologramLine extends FloatingDoubleEntity {
|
|||||||
skull = null;
|
skull = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void teleport(double x, double y, double z) {
|
||||||
|
if (skull != null) {
|
||||||
|
skull.setLocationNMS(x, y + VERTICAL_OFFSET, z);
|
||||||
|
skull.sendUpdatePacketNear();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.gmail.filoghost.holograms.object.pieces;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import com.gmail.filoghost.holograms.exception.SpawnFailedException;
|
||||||
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
|
// Represents an object associated with a hologram, made of a wither skull with a passenger.
|
||||||
|
public abstract class FloatingDoubleEntity {
|
||||||
|
|
||||||
|
public abstract void spawn(HologramBase parent, World bukkitWorld, double x, double y, double z) throws SpawnFailedException;
|
||||||
|
|
||||||
|
public abstract void despawn();
|
||||||
|
|
||||||
|
public abstract void teleport(double x, double y, double z);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
package com.gmail.filoghost.holograms.object.pieces;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.gmail.filoghost.holograms.exception.SpawnFailedException;
|
||||||
|
import com.gmail.filoghost.holograms.nms.interfaces.CustomItem;
|
||||||
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramWitherSkull;
|
||||||
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
|
import static com.gmail.filoghost.holograms.HolographicDisplays.nmsManager;
|
||||||
|
|
||||||
|
public class FloatingItemDoubleEntity extends FloatingDoubleEntity {
|
||||||
|
|
||||||
|
private static final double VERTICAL_OFFSET = -0.21;
|
||||||
|
|
||||||
|
private ItemStack itemStack;
|
||||||
|
private CustomItem item;
|
||||||
|
private HologramWitherSkull skull;
|
||||||
|
|
||||||
|
private boolean allowPickup;
|
||||||
|
|
||||||
|
public FloatingItemDoubleEntity(ItemStack itemStack) {
|
||||||
|
this.itemStack = itemStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void spawn(HologramBase parent, World bukkitWorld, double x, double y, double z) throws SpawnFailedException {
|
||||||
|
despawn();
|
||||||
|
|
||||||
|
item = nmsManager.spawnCustomItem(bukkitWorld, x, y + VERTICAL_OFFSET, z, itemStack);
|
||||||
|
item.setParentHologram(parent);
|
||||||
|
|
||||||
|
item.allowPickup(allowPickup);
|
||||||
|
|
||||||
|
skull = nmsManager.spawnHologramWitherSkull(bukkitWorld, x, y + VERTICAL_OFFSET, z);
|
||||||
|
skull.setParentHologram(parent);
|
||||||
|
|
||||||
|
// Let the item ride the wither skull.
|
||||||
|
skull.setPassengerNMS(item);
|
||||||
|
|
||||||
|
item.setLockTick(true);
|
||||||
|
skull.setLockTick(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void despawn() {
|
||||||
|
if (item != null) {
|
||||||
|
item.killEntityNMS();
|
||||||
|
item = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skull != null) {
|
||||||
|
skull.killEntityNMS();
|
||||||
|
skull = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSpawned() {
|
||||||
|
return item != null && skull != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getItemStack() {
|
||||||
|
return itemStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemStack(ItemStack itemStack) {
|
||||||
|
this.itemStack = itemStack;
|
||||||
|
if (isSpawned()) {
|
||||||
|
item.setItemStackNMS(itemStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllowPickup(boolean allowPickup) {
|
||||||
|
this.allowPickup = allowPickup;
|
||||||
|
if (item != null) {
|
||||||
|
item.allowPickup(allowPickup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void teleport(double x, double y, double z) {
|
||||||
|
if (skull != null) {
|
||||||
|
skull.setLocationNMS(x, y + VERTICAL_OFFSET, z);
|
||||||
|
skull.sendUpdatePacketNear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,24 +1,26 @@
|
|||||||
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.HologramWitherSkull;
|
import com.gmail.filoghost.holograms.nms.interfaces.HologramWitherSkull;
|
||||||
import com.gmail.filoghost.holograms.nms.interfaces.TouchSlime;
|
import com.gmail.filoghost.holograms.nms.interfaces.TouchSlime;
|
||||||
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
import static com.gmail.filoghost.holograms.HolographicDisplays.nmsManager;
|
import static com.gmail.filoghost.holograms.HolographicDisplays.nmsManager;
|
||||||
|
|
||||||
public class FloatingTouchSlime extends FloatingDoubleEntity {
|
public class FloatingTouchSlimeDoubleEntity extends FloatingDoubleEntity {
|
||||||
|
|
||||||
private static final double VERTICAL_OFFSET = -0.3;
|
private static final double VERTICAL_OFFSET = -0.3;
|
||||||
|
|
||||||
private TouchSlime slime;
|
private TouchSlime slime;
|
||||||
private HologramWitherSkull skull;
|
private HologramWitherSkull skull;
|
||||||
|
|
||||||
public FloatingTouchSlime() {
|
public FloatingTouchSlimeDoubleEntity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(CraftHologram parent, World bukkitWorld, double x, double y, double z) throws SpawnFailedException {
|
public void spawn(HologramBase parent, World bukkitWorld, double x, double y, double z) throws SpawnFailedException {
|
||||||
despawn();
|
despawn();
|
||||||
|
|
||||||
slime = nmsManager.spawnTouchSlime(bukkitWorld, x, y + VERTICAL_OFFSET, z);
|
slime = nmsManager.spawnTouchSlime(bukkitWorld, x, y + VERTICAL_OFFSET, z);
|
||||||
@ -50,4 +52,12 @@ public class FloatingTouchSlime extends FloatingDoubleEntity {
|
|||||||
public boolean isSpawned() {
|
public boolean isSpawned() {
|
||||||
return slime != null && skull != null;
|
return slime != null && skull != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void teleport(double x, double y, double z) {
|
||||||
|
if (skull != null) {
|
||||||
|
skull.setLocationNMS(x, y + VERTICAL_OFFSET, z);
|
||||||
|
skull.sendUpdatePacketNear();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -17,6 +17,8 @@ import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
|||||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||||
import com.gmail.filoghost.holograms.HolographicDisplays;
|
import com.gmail.filoghost.holograms.HolographicDisplays;
|
||||||
import com.gmail.filoghost.holograms.object.CraftHologram;
|
import com.gmail.filoghost.holograms.object.CraftHologram;
|
||||||
|
import com.gmail.filoghost.holograms.object.HologramBase;
|
||||||
|
|
||||||
import static com.gmail.filoghost.holograms.HolographicDisplays.nmsManager;
|
import static com.gmail.filoghost.holograms.HolographicDisplays.nmsManager;
|
||||||
|
|
||||||
public class ProtocolLibHook {
|
public class ProtocolLibHook {
|
||||||
@ -136,6 +138,11 @@ public class ProtocolLibHook {
|
|||||||
|
|
||||||
// Horses are always part of a CraftHologram
|
// Horses are always part of a CraftHologram
|
||||||
private static CraftHologram getHologram(Entity bukkitEntity) {
|
private static CraftHologram getHologram(Entity bukkitEntity) {
|
||||||
return (CraftHologram) nmsManager.getParentHologram(bukkitEntity);
|
HologramBase base = nmsManager.getParentHologram(bukkitEntity);
|
||||||
|
if (base instanceof CraftHologram) {
|
||||||
|
return (CraftHologram) base;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user