mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-09-07 21:18:14 +02:00
Fix icons being picked up & add per command permissions.
This commit is contained in:
parent
8ea4488028
commit
0b47982927
@ -139,7 +139,7 @@ public class HolographicDisplays extends JavaPlugin {
|
|||||||
"******************************************************",
|
"******************************************************",
|
||||||
" This version of HolographicDisplays can",
|
" This version of HolographicDisplays can",
|
||||||
" only work on these server versions:",
|
" 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.",
|
" The plugin will be disabled.",
|
||||||
"******************************************************"
|
"******************************************************"
|
||||||
);
|
);
|
||||||
|
@ -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 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 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.";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ public class AddlineCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
public AddlineCommand() {
|
public AddlineCommand() {
|
||||||
super("addline");
|
super("addline");
|
||||||
setPermission(Messages.MAIN_PERMISSION);
|
setPermission(Messages.BASE_PERM + "addline");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,7 +24,7 @@ public class CreateCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
public CreateCommand() {
|
public CreateCommand() {
|
||||||
super("create");
|
super("create");
|
||||||
setPermission(Messages.MAIN_PERMISSION);
|
setPermission(Messages.BASE_PERM + "create");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -38,6 +38,7 @@ public class CreateCommand extends HologramSubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) throws CommandException {
|
public void execute(CommandSender sender, String[] args) throws CommandException {
|
||||||
try {
|
try {
|
||||||
@ -45,12 +46,19 @@ public class CreateCommand extends HologramSubCommand {
|
|||||||
String name = StringUtils.validateName(args[0].toLowerCase());
|
String name = StringUtils.validateName(args[0].toLowerCase());
|
||||||
CommandValidator.isTrue(!HologramManager.isExistingHologram(name), "A hologram with that name already exists.");
|
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);
|
HologramManager.addHologram(hologram);
|
||||||
|
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
hologram.addLine(StringUtils.toReadableFormat(StringUtils.join(args, " ", 1, args.length)));
|
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 {
|
} else {
|
||||||
hologram.addLine("Default hologram. Change it with " + Format.HIGHLIGHT + "/hd edit " + hologram.getName());
|
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.teleport(look, TeleportCause.PLUGIN);
|
||||||
player.sendMessage(Format.HIGHLIGHT + "You created a hologram named '" + hologram.getName() + "'.");
|
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) {
|
} catch (InvalidCharactersException ex) {
|
||||||
throw new CommandException("The hologram's name must be alphanumeric. '" + ex.getMessage() + "' is not allowed.");
|
throw new CommandException("The hologram's name must be alphanumeric. '" + ex.getMessage() + "' is not allowed.");
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public class DeleteCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
public DeleteCommand() {
|
public DeleteCommand() {
|
||||||
super("delete", "remove");
|
super("delete", "remove");
|
||||||
setPermission(Messages.MAIN_PERMISSION);
|
setPermission(Messages.BASE_PERM + "delete");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,7 +29,7 @@ public class EditCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
public EditCommand() {
|
public EditCommand() {
|
||||||
super("edit");
|
super("edit");
|
||||||
setPermission(Messages.MAIN_PERMISSION);
|
setPermission(Messages.BASE_PERM + "edit");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -18,7 +18,7 @@ public class FixCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
public FixCommand() {
|
public FixCommand() {
|
||||||
super("fix", "light");
|
super("fix", "light");
|
||||||
setPermission(Messages.MAIN_PERMISSION);
|
setPermission(Messages.BASE_PERM + "fix");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,7 +21,7 @@ public class HelpCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
public HelpCommand() {
|
public HelpCommand() {
|
||||||
super("help");
|
super("help");
|
||||||
setPermission(Messages.MAIN_PERMISSION);
|
setPermission(Messages.BASE_PERM + "help");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,7 +20,7 @@ public class InsertlineCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
public InsertlineCommand() {
|
public InsertlineCommand() {
|
||||||
super("insertline");
|
super("insertline");
|
||||||
setPermission(Messages.MAIN_PERMISSION);
|
setPermission(Messages.BASE_PERM + "insertline");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,7 +19,7 @@ public class ListCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
public ListCommand() {
|
public ListCommand() {
|
||||||
super("list");
|
super("list");
|
||||||
setPermission(Messages.MAIN_PERMISSION);
|
setPermission(Messages.BASE_PERM + "list");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,7 +22,7 @@ public class MovehereCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
public MovehereCommand() {
|
public MovehereCommand() {
|
||||||
super("movehere");
|
super("movehere");
|
||||||
setPermission(Messages.MAIN_PERMISSION);
|
setPermission(Messages.BASE_PERM + "movehere");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,7 +20,7 @@ public class NearCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
public NearCommand() {
|
public NearCommand() {
|
||||||
super("near");
|
super("near");
|
||||||
setPermission(Messages.MAIN_PERMISSION);
|
setPermission(Messages.BASE_PERM + "near");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,7 +26,7 @@ public class ReadimageCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
public ReadimageCommand() {
|
public ReadimageCommand() {
|
||||||
super("readimage", "image");
|
super("readimage", "image");
|
||||||
setPermission(Messages.MAIN_PERMISSION);
|
setPermission(Messages.BASE_PERM + "readimage");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,7 +22,7 @@ public class ReadtextCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
public ReadtextCommand() {
|
public ReadtextCommand() {
|
||||||
super("readtext", "readlines");
|
super("readtext", "readlines");
|
||||||
setPermission(Messages.MAIN_PERMISSION);
|
setPermission(Messages.BASE_PERM + "readtext");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,7 +26,7 @@ public class ReloadCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
public ReloadCommand() {
|
public ReloadCommand() {
|
||||||
super("reload");
|
super("reload");
|
||||||
setPermission(Messages.MAIN_PERMISSION);
|
setPermission(Messages.BASE_PERM + "reload");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -18,7 +18,7 @@ public class RemovelineCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
public RemovelineCommand() {
|
public RemovelineCommand() {
|
||||||
super("removeline");
|
super("removeline");
|
||||||
setPermission(Messages.MAIN_PERMISSION);
|
setPermission(Messages.BASE_PERM + "removeline");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,7 +16,7 @@ public class SaveCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
public SaveCommand() {
|
public SaveCommand() {
|
||||||
super("save");
|
super("save");
|
||||||
setPermission(Messages.MAIN_PERMISSION);
|
setPermission(Messages.BASE_PERM + "save");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,7 +19,7 @@ public class SetlineCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
public SetlineCommand() {
|
public SetlineCommand() {
|
||||||
super("setline");
|
super("setline");
|
||||||
setPermission(Messages.MAIN_PERMISSION);
|
setPermission(Messages.BASE_PERM + "setline");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,7 +20,7 @@ public class TeleportCommand extends HologramSubCommand {
|
|||||||
|
|
||||||
public TeleportCommand() {
|
public TeleportCommand() {
|
||||||
super("teleport", "tp");
|
super("teleport", "tp");
|
||||||
setPermission(Messages.MAIN_PERMISSION);
|
setPermission(Messages.BASE_PERM + "teleport");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -103,7 +103,7 @@ public class MainListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoin(PlayerJoinEvent event) {
|
public void onJoin(PlayerJoinEvent event) {
|
||||||
if (Configuration.updateNotification && Configuration.newVersion != null) {
|
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[HolographicDisplays] §bFound an update: " + Configuration.newVersion + ". Download:");
|
||||||
event.getPlayer().sendMessage("§3>> §bhttp://dev.bukkit.org/bukkit-plugins/holographic-displays");
|
event.getPlayer().sendMessage("§3>> §bhttp://dev.bukkit.org/bukkit-plugins/holographic-displays");
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.filoghost.holograms.nms.v1_6_R3;
|
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.EntityItem;
|
||||||
import net.minecraft.server.v1_6_R3.ItemStack;
|
import net.minecraft.server.v1_6_R3.ItemStack;
|
||||||
import net.minecraft.server.v1_6_R3.NBTTagCompound;
|
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 {
|
public class EntityCustomItem extends EntityItem implements CustomItem, BasicEntityNMS {
|
||||||
|
|
||||||
private static final ItemStack STONE = new ItemStack(Block.STONE, 0);
|
|
||||||
|
|
||||||
private boolean lockTick;
|
private boolean lockTick;
|
||||||
private HologramBase parent;
|
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.
|
// Method called when a player is near.
|
||||||
@Override
|
@Override
|
||||||
public void b_(EntityHuman human) {
|
public void b_(EntityHuman human) {
|
||||||
@ -91,11 +99,6 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getItemStack() {
|
|
||||||
return STONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLockTick(boolean lock) {
|
public void setLockTick(boolean lock) {
|
||||||
lockTick = lock;
|
lockTick = lock;
|
||||||
|
@ -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.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.EntityHuman;
|
import net.minecraft.server.v1_7_R1.EntityHuman;
|
||||||
import net.minecraft.server.v1_7_R1.EntityPlayer;
|
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 boolean lockTick;
|
private boolean lockTick;
|
||||||
private HologramBase parent;
|
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.
|
// Method called when a player is near.
|
||||||
@Override
|
@Override
|
||||||
public void b_(EntityHuman human) {
|
public void b_(EntityHuman human) {
|
||||||
@ -91,11 +99,6 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getItemStack() {
|
|
||||||
return STONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLockTick(boolean lock) {
|
public void setLockTick(boolean lock) {
|
||||||
lockTick = lock;
|
lockTick = lock;
|
||||||
|
@ -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.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.EntityHuman;
|
import net.minecraft.server.v1_7_R2.EntityHuman;
|
||||||
import net.minecraft.server.v1_7_R2.EntityPlayer;
|
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 boolean lockTick;
|
private boolean lockTick;
|
||||||
private HologramBase parent;
|
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.
|
// Method called when a player is near.
|
||||||
@Override
|
@Override
|
||||||
public void b_(EntityHuman human) {
|
public void b_(EntityHuman human) {
|
||||||
@ -91,11 +99,6 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getItemStack() {
|
|
||||||
return STONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLockTick(boolean lock) {
|
public void setLockTick(boolean lock) {
|
||||||
lockTick = lock;
|
lockTick = lock;
|
||||||
|
@ -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.nms.interfaces.CustomItem;
|
||||||
import com.gmail.filoghost.holograms.object.HologramBase;
|
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.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;
|
||||||
@ -19,8 +18,6 @@ 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 boolean lockTick;
|
private boolean lockTick;
|
||||||
private HologramBase parent;
|
private HologramBase parent;
|
||||||
|
|
||||||
@ -31,7 +28,6 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void h() {
|
public void h() {
|
||||||
// Checks every 20 ticks.
|
|
||||||
if (ticksLived % 20 == 0) {
|
if (ticksLived % 20 == 0) {
|
||||||
// The item dies without a vehicle.
|
// The item dies without a vehicle.
|
||||||
if (this.vehicle == null) {
|
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.
|
// Method called when a player is near.
|
||||||
@Override
|
@Override
|
||||||
public void b_(EntityHuman human) {
|
public void b_(EntityHuman human) {
|
||||||
@ -96,11 +103,6 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt
|
|||||||
lockTick = lock;
|
lockTick = lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getItemStack() {
|
|
||||||
return STONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void die() {
|
public void die() {
|
||||||
setLockTick(false);
|
setLockTick(false);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
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.Blocks;
|
|
||||||
import net.minecraft.server.v1_7_R4.EntityHuman;
|
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.EntityPlayer;
|
||||||
@ -19,8 +18,6 @@ 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 boolean lockTick;
|
private boolean lockTick;
|
||||||
private HologramBase parent;
|
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.
|
// Method called when a player is near.
|
||||||
@Override
|
@Override
|
||||||
public void b_(EntityHuman human) {
|
public void b_(EntityHuman human) {
|
||||||
@ -96,11 +104,6 @@ public class EntityCustomItem extends EntityItem implements CustomItem, BasicEnt
|
|||||||
lockTick = lock;
|
lockTick = lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getItemStack() {
|
|
||||||
return STONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void die() {
|
public void die() {
|
||||||
setLockTick(false);
|
setLockTick(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user