public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (!world.isRemote) {
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("time", NBT.TAG_LONG)) {
if (world.getTotalWorldTime() >= stack.getTagCompound().getLong("time")) {
//Задержка указывается в тиках, 20 тиков - 1 секунда.
stack.getTagCompound().setLong("time", (long) (world.getTotalWorldTime() + 100));
System.out.println("start");
player.addChatMessage(new ChatComponentText("§8[§cМалышка§8] §8Лиза §8: " + "§astart"));
}
else {
System.out.println("execution");
player.addChatMessage(new ChatComponentText("§8[§cМалышка§8] §8Лиза §8: " + "§aexecution"));
}
} else {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setLong("time", (long) (world.getTotalWorldTime() + 100));
stack.setTagCompound(nbt);
}
}
return stack;
}
public void onUpdate(ItemStack stack, World world, Entity entity, int p_77663_4_, boolean p_77663_5_) {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (!world.isRemote && entity instanceof EntityLivingBase) {
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("time", NBT.TAG_LONG)) {
if (world.getTotalWorldTime() == stack.getTagCompound().getLong("time")) {
//Код, который будет выполняться после задержки.
System.out.println("end");
player.addChatMessage(new ChatComponentText("§8[§cМалышка§8] §8Лиза §8: " + "§aend"));
--stack.stackSize;
}
}
}
}