From 0b47982927fb47f1ea0fede20fda11c597f0d4b6 Mon Sep 17 00:00:00 2001 From: filoghost Date: Mon, 11 Aug 2014 21:22:29 +0200 Subject: [PATCH] Fix icons being picked up & add per command permissions. --- .../holograms/HolographicDisplays.java | 4 ++-- .../holograms/commands/Messages.java | 2 +- .../commands/main/subs/AddlineCommand.java | 2 +- .../commands/main/subs/CreateCommand.java | 20 +++++++++++++++---- .../commands/main/subs/DeleteCommand.java | 2 +- .../commands/main/subs/EditCommand.java | 2 +- .../commands/main/subs/FixCommand.java | 2 +- .../commands/main/subs/HelpCommand.java | 2 +- .../commands/main/subs/InsertlineCommand.java | 2 +- .../commands/main/subs/ListCommand.java | 2 +- .../commands/main/subs/MovehereCommand.java | 2 +- .../commands/main/subs/NearCommand.java | 2 +- .../commands/main/subs/ReadimageCommand.java | 2 +- .../commands/main/subs/ReadtextCommand.java | 2 +- .../commands/main/subs/ReloadCommand.java | 2 +- .../commands/main/subs/RemovelineCommand.java | 2 +- .../commands/main/subs/SaveCommand.java | 2 +- .../commands/main/subs/SetlineCommand.java | 2 +- .../commands/main/subs/TeleportCommand.java | 2 +- .../holograms/listener/MainListener.java | 2 +- .../nms/v1_6_R3/EntityCustomItem.java | 19 ++++++++++-------- .../nms/v1_7_R1/EntityCustomItem.java | 19 ++++++++++-------- .../nms/v1_7_R2/EntityCustomItem.java | 19 ++++++++++-------- .../nms/v1_7_R3/EntityCustomItem.java | 20 ++++++++++--------- .../nms/v1_7_R4/EntityCustomItem.java | 19 ++++++++++-------- 25 files changed, 91 insertions(+), 65 deletions(-) diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/HolographicDisplays.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/HolographicDisplays.java index 4ee89909..c5f34dac 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/HolographicDisplays.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/HolographicDisplays.java @@ -139,13 +139,13 @@ public class HolographicDisplays extends JavaPlugin { "******************************************************", " This version of HolographicDisplays can", " only work on these server versions:", - " 1.6.4, from 1.7.2 to 1.7.9.", + " 1.6.4, from 1.7.2 to 1.7.10.", " The plugin will be disabled.", "******************************************************" ); return; } - + try { if (VersionUtils.isMCPC() || VersionUtils.isCauldron()) { getLogger().info("Trying to enable Cauldron/MCPC+ support..."); diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/Messages.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/Messages.java index 54422a88..a407e907 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/Messages.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/Messages.java @@ -8,6 +8,6 @@ public class Messages { public static final String NO_SUCH_HOLOGRAM = ChatColor.RED + "A hologram with that name doesn't exist."; public static final String FAILED_TO_SPAWN_HERE = ChatColor.GRAY + "(The entities failed to spawn. You MUST allow mobs to spawn here.)"; - public static final String MAIN_PERMISSION = "holograms.admin"; + public static final String BASE_PERM = "holograms."; } diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/AddlineCommand.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/AddlineCommand.java index 59d00f72..a0fe83c1 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/AddlineCommand.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/AddlineCommand.java @@ -19,7 +19,7 @@ public class AddlineCommand extends HologramSubCommand { public AddlineCommand() { super("addline"); - setPermission(Messages.MAIN_PERMISSION); + setPermission(Messages.BASE_PERM + "addline"); } @Override diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/CreateCommand.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/CreateCommand.java index 3aaf078e..0f9e025d 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/CreateCommand.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/CreateCommand.java @@ -24,7 +24,7 @@ public class CreateCommand extends HologramSubCommand { public CreateCommand() { super("create"); - setPermission(Messages.MAIN_PERMISSION); + setPermission(Messages.BASE_PERM + "create"); } @Override @@ -38,19 +38,27 @@ public class CreateCommand extends HologramSubCommand { } + @SuppressWarnings("deprecation") @Override public void execute(CommandSender sender, String[] args) throws CommandException { try { Player player = CommandValidator.getPlayerSender(sender); String name = StringUtils.validateName(args[0].toLowerCase()); CommandValidator.isTrue(!HologramManager.isExistingHologram(name), "A hologram with that name already exists."); - - CraftHologram hologram = new CraftHologram(name, player.getLocation()); + + Location spawnLoc = player.getLocation(); + boolean moveUp = player.isOnGround(); + + if (moveUp) { + spawnLoc.add(0.0, 1.2, 0.0); + } + + CraftHologram hologram = new CraftHologram(name, spawnLoc); HologramManager.addHologram(hologram); if (args.length > 1) { hologram.addLine(StringUtils.toReadableFormat(StringUtils.join(args, " ", 1, args.length))); - sender.sendMessage("§7(Change the lines with /hd edit " + hologram.getName() + ")"); + player.sendMessage("§7(Change the lines with /hd edit " + hologram.getName() + ")"); } else { hologram.addLine("Default hologram. Change it with " + Format.HIGHLIGHT + "/hd edit " + hologram.getName()); } @@ -66,6 +74,10 @@ public class CreateCommand extends HologramSubCommand { player.teleport(look, TeleportCause.PLUGIN); player.sendMessage(Format.HIGHLIGHT + "You created a hologram named '" + hologram.getName() + "'."); + if (moveUp) { + player.sendMessage("§7(You were on the ground, the hologram was automatically moved up. If you use /hd movehere " + hologram.getName() + ", the hologram will be moved to your feet)"); + } + } catch (InvalidCharactersException ex) { throw new CommandException("The hologram's name must be alphanumeric. '" + ex.getMessage() + "' is not allowed."); } diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/DeleteCommand.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/DeleteCommand.java index d8f27dd8..cc6d3d6d 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/DeleteCommand.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/DeleteCommand.java @@ -18,7 +18,7 @@ public class DeleteCommand extends HologramSubCommand { public DeleteCommand() { super("delete", "remove"); - setPermission(Messages.MAIN_PERMISSION); + setPermission(Messages.BASE_PERM + "delete"); } @Override diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/EditCommand.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/EditCommand.java index be8eb700..6b06abdb 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/EditCommand.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/EditCommand.java @@ -29,7 +29,7 @@ public class EditCommand extends HologramSubCommand { public EditCommand() { super("edit"); - setPermission(Messages.MAIN_PERMISSION); + setPermission(Messages.BASE_PERM + "edit"); } @Override diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/FixCommand.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/FixCommand.java index 74b56725..2a295d5b 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/FixCommand.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/FixCommand.java @@ -18,7 +18,7 @@ public class FixCommand extends HologramSubCommand { public FixCommand() { super("fix", "light"); - setPermission(Messages.MAIN_PERMISSION); + setPermission(Messages.BASE_PERM + "fix"); } @Override diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/HelpCommand.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/HelpCommand.java index 8d0ab10c..5d68af31 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/HelpCommand.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/HelpCommand.java @@ -21,7 +21,7 @@ public class HelpCommand extends HologramSubCommand { public HelpCommand() { super("help"); - setPermission(Messages.MAIN_PERMISSION); + setPermission(Messages.BASE_PERM + "help"); } @Override diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/InsertlineCommand.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/InsertlineCommand.java index 4044e38d..92897860 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/InsertlineCommand.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/InsertlineCommand.java @@ -20,7 +20,7 @@ public class InsertlineCommand extends HologramSubCommand { public InsertlineCommand() { super("insertline"); - setPermission(Messages.MAIN_PERMISSION); + setPermission(Messages.BASE_PERM + "insertline"); } @Override diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/ListCommand.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/ListCommand.java index e622d64b..2a37a69a 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/ListCommand.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/ListCommand.java @@ -19,7 +19,7 @@ public class ListCommand extends HologramSubCommand { public ListCommand() { super("list"); - setPermission(Messages.MAIN_PERMISSION); + setPermission(Messages.BASE_PERM + "list"); } @Override diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/MovehereCommand.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/MovehereCommand.java index 09e2274b..1e1e25a9 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/MovehereCommand.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/MovehereCommand.java @@ -22,7 +22,7 @@ public class MovehereCommand extends HologramSubCommand { public MovehereCommand() { super("movehere"); - setPermission(Messages.MAIN_PERMISSION); + setPermission(Messages.BASE_PERM + "movehere"); } @Override diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/NearCommand.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/NearCommand.java index 4a2d0702..2a6d0c8d 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/NearCommand.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/NearCommand.java @@ -20,7 +20,7 @@ public class NearCommand extends HologramSubCommand { public NearCommand() { super("near"); - setPermission(Messages.MAIN_PERMISSION); + setPermission(Messages.BASE_PERM + "near"); } @Override diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/ReadimageCommand.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/ReadimageCommand.java index 4425344a..5c5cb31f 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/ReadimageCommand.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/ReadimageCommand.java @@ -26,7 +26,7 @@ public class ReadimageCommand extends HologramSubCommand { public ReadimageCommand() { super("readimage", "image"); - setPermission(Messages.MAIN_PERMISSION); + setPermission(Messages.BASE_PERM + "readimage"); } @Override diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/ReadtextCommand.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/ReadtextCommand.java index 81717286..7bfbad86 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/ReadtextCommand.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/ReadtextCommand.java @@ -22,7 +22,7 @@ public class ReadtextCommand extends HologramSubCommand { public ReadtextCommand() { super("readtext", "readlines"); - setPermission(Messages.MAIN_PERMISSION); + setPermission(Messages.BASE_PERM + "readtext"); } @Override diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/ReloadCommand.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/ReloadCommand.java index 9e9f2493..6f1d1849 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/ReloadCommand.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/ReloadCommand.java @@ -26,7 +26,7 @@ public class ReloadCommand extends HologramSubCommand { public ReloadCommand() { super("reload"); - setPermission(Messages.MAIN_PERMISSION); + setPermission(Messages.BASE_PERM + "reload"); } @Override diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/RemovelineCommand.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/RemovelineCommand.java index 5dadd920..86bbe205 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/RemovelineCommand.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/RemovelineCommand.java @@ -18,7 +18,7 @@ public class RemovelineCommand extends HologramSubCommand { public RemovelineCommand() { super("removeline"); - setPermission(Messages.MAIN_PERMISSION); + setPermission(Messages.BASE_PERM + "removeline"); } @Override diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/SaveCommand.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/SaveCommand.java index f2c4c0cd..29773eb8 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/SaveCommand.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/SaveCommand.java @@ -16,7 +16,7 @@ public class SaveCommand extends HologramSubCommand { public SaveCommand() { super("save"); - setPermission(Messages.MAIN_PERMISSION); + setPermission(Messages.BASE_PERM + "save"); } @Override diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/SetlineCommand.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/SetlineCommand.java index 879a58af..1317e21f 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/SetlineCommand.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/SetlineCommand.java @@ -19,7 +19,7 @@ public class SetlineCommand extends HologramSubCommand { public SetlineCommand() { super("setline"); - setPermission(Messages.MAIN_PERMISSION); + setPermission(Messages.BASE_PERM + "setline"); } @Override diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/TeleportCommand.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/TeleportCommand.java index e731987d..22e5767c 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/TeleportCommand.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/commands/main/subs/TeleportCommand.java @@ -20,7 +20,7 @@ public class TeleportCommand extends HologramSubCommand { public TeleportCommand() { super("teleport", "tp"); - setPermission(Messages.MAIN_PERMISSION); + setPermission(Messages.BASE_PERM + "teleport"); } @Override diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/listener/MainListener.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/listener/MainListener.java index 77b16d64..7a239a4b 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/listener/MainListener.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/listener/MainListener.java @@ -103,7 +103,7 @@ public class MainListener implements Listener { @EventHandler public void onJoin(PlayerJoinEvent event) { if (Configuration.updateNotification && Configuration.newVersion != null) { - if (event.getPlayer().hasPermission(Messages.MAIN_PERMISSION)) { + if (event.getPlayer().hasPermission(Messages.BASE_PERM + "update")) { event.getPlayer().sendMessage("§3[HolographicDisplays] §bFound an update: " + Configuration.newVersion + ". Download:"); event.getPlayer().sendMessage("§3>> §bhttp://dev.bukkit.org/bukkit-plugins/holographic-displays"); } diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_6_R3/EntityCustomItem.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_6_R3/EntityCustomItem.java index 3119b334..139673c1 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_6_R3/EntityCustomItem.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_6_R3/EntityCustomItem.java @@ -1,6 +1,5 @@ package com.gmail.filoghost.holograms.nms.v1_6_R3; -import net.minecraft.server.v1_6_R3.Block; import net.minecraft.server.v1_6_R3.EntityItem; import net.minecraft.server.v1_6_R3.ItemStack; import net.minecraft.server.v1_6_R3.NBTTagCompound; @@ -19,8 +18,6 @@ import com.gmail.filoghost.holograms.object.HologramBase; public class EntityCustomItem extends EntityItem implements CustomItem, BasicEntityNMS { - private static final ItemStack STONE = new ItemStack(Block.STONE, 0); - private boolean lockTick; private HologramBase parent; @@ -44,6 +41,17 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt } } + @Override + public ItemStack getItemStack() { + // Dirty method to check if the icon is being picked up + StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace(); + if (stacktrace.length >= 2 && stacktrace[1].getClassName().contains("EntityInsentient")) { + return null; // Try to pickup this, dear entity ignoring the pickupDelay! + } + + return super.getItemStack(); + } + // Method called when a player is near. @Override public void b_(EntityHuman human) { @@ -90,11 +98,6 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt */ return true; } - - @Override - public ItemStack getItemStack() { - return STONE; - } @Override public void setLockTick(boolean lock) { diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R1/EntityCustomItem.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R1/EntityCustomItem.java index c7cc182a..d4b6269e 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R1/EntityCustomItem.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R1/EntityCustomItem.java @@ -13,14 +13,11 @@ import net.minecraft.server.v1_7_R1.EntityItem; import net.minecraft.server.v1_7_R1.ItemStack; import net.minecraft.server.v1_7_R1.NBTTagCompound; import net.minecraft.server.v1_7_R1.World; -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 { - private static final ItemStack STONE = new ItemStack(Blocks.STONE, 0); - private boolean lockTick; private HologramBase parent; @@ -44,6 +41,17 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt } } + @Override + public ItemStack getItemStack() { + // Dirty method to check if the icon is being picked up + StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace(); + if (stacktrace.length >= 2 && stacktrace[1].getClassName().contains("EntityInsentient")) { + return null; // Try to pickup this, dear entity ignoring the pickupDelay! + } + + return super.getItemStack(); + } + // Method called when a player is near. @Override public void b_(EntityHuman human) { @@ -90,11 +98,6 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt */ return true; } - - @Override - public ItemStack getItemStack() { - return STONE; - } @Override public void setLockTick(boolean lock) { diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R2/EntityCustomItem.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R2/EntityCustomItem.java index aea5a2b7..06ffb16e 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R2/EntityCustomItem.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R2/EntityCustomItem.java @@ -13,14 +13,11 @@ import net.minecraft.server.v1_7_R2.EntityItem; import net.minecraft.server.v1_7_R2.ItemStack; import net.minecraft.server.v1_7_R2.NBTTagCompound; import net.minecraft.server.v1_7_R2.World; -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 { - private static final ItemStack STONE = new ItemStack(Blocks.STONE, 0); - private boolean lockTick; private HologramBase parent; @@ -44,6 +41,17 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt } } + @Override + public ItemStack getItemStack() { + // Dirty method to check if the icon is being picked up + StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace(); + if (stacktrace.length >= 2 && stacktrace[1].getClassName().contains("EntityInsentient")) { + return null; // Try to pickup this, dear entity ignoring the pickupDelay! + } + + return super.getItemStack(); + } + // Method called when a player is near. @Override public void b_(EntityHuman human) { @@ -90,11 +98,6 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt */ return true; } - - @Override - public ItemStack getItemStack() { - return STONE; - } @Override public void setLockTick(boolean lock) { diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R3/EntityCustomItem.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R3/EntityCustomItem.java index e8177937..772f4e9d 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R3/EntityCustomItem.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R3/EntityCustomItem.java @@ -9,7 +9,6 @@ import com.gmail.filoghost.holograms.nms.interfaces.BasicEntityNMS; import com.gmail.filoghost.holograms.nms.interfaces.CustomItem; import com.gmail.filoghost.holograms.object.HologramBase; -import net.minecraft.server.v1_7_R3.Blocks; import net.minecraft.server.v1_7_R3.EntityItem; import net.minecraft.server.v1_7_R3.ItemStack; import net.minecraft.server.v1_7_R3.NBTTagCompound; @@ -19,8 +18,6 @@ import net.minecraft.server.v1_7_R3.EntityPlayer; public class EntityCustomItem extends EntityItem implements CustomItem, BasicEntityNMS { - private static final ItemStack STONE = new ItemStack(Blocks.STONE, 0); - private boolean lockTick; private HologramBase parent; @@ -31,7 +28,6 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt @Override public void h() { - // Checks every 20 ticks. if (ticksLived % 20 == 0) { // The item dies without a vehicle. if (this.vehicle == null) { @@ -44,6 +40,17 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt } } + @Override + public ItemStack getItemStack() { + // Dirty method to check if the icon is being picked up + StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace(); + if (stacktrace.length >= 2 && stacktrace[1].getClassName().contains("EntityInsentient")) { + return null; // Try to pickup this, dear entity ignoring the pickupDelay! + } + + return super.getItemStack(); + } + // Method called when a player is near. @Override public void b_(EntityHuman human) { @@ -96,11 +103,6 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt lockTick = lock; } - @Override - public ItemStack getItemStack() { - return STONE; - } - @Override public void die() { setLockTick(false); diff --git a/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R4/EntityCustomItem.java b/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R4/EntityCustomItem.java index 077f42ca..58f39e04 100644 --- a/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R4/EntityCustomItem.java +++ b/HolographicDisplays/src/com/gmail/filoghost/holograms/nms/v1_7_R4/EntityCustomItem.java @@ -1,6 +1,5 @@ package com.gmail.filoghost.holograms.nms.v1_7_R4; -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.EntityPlayer; @@ -19,8 +18,6 @@ import com.gmail.filoghost.holograms.object.HologramBase; public class EntityCustomItem extends EntityItem implements CustomItem, BasicEntityNMS { - private static final ItemStack STONE = new ItemStack(Blocks.STONE, 0); - private boolean lockTick; private HologramBase parent; @@ -44,6 +41,17 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt } } + @Override + public ItemStack getItemStack() { + // Dirty method to check if the icon is being picked up + StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace(); + if (stacktrace.length >= 2 && stacktrace[1].getClassName().contains("EntityInsentient")) { + return null; // Try to pickup this, dear entity ignoring the pickupDelay! + } + + return super.getItemStack(); + } + // Method called when a player is near. @Override public void b_(EntityHuman human) { @@ -96,11 +104,6 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt lockTick = lock; } - @Override - public ItemStack getItemStack() { - return STONE; - } - @Override public void die() { setLockTick(false);