From 311a82d15bdac050d262fadc241035b5942ac01b Mon Sep 17 00:00:00 2001 From: StrangeMan1580 <86133978+StrangeMan1580@users.noreply.github.com> Date: Sat, 9 Apr 2022 16:43:56 +0300 Subject: [PATCH 01/75] Update ru_RU.lang --- .../assets/customnpcs/lang/ru_RU.lang | 1182 ++++++++++------- 1 file changed, 689 insertions(+), 493 deletions(-) diff --git a/src/main/resources/assets/customnpcs/lang/ru_RU.lang b/src/main/resources/assets/customnpcs/lang/ru_RU.lang index d00b62f4f..f6f3d74ad 100644 --- a/src/main/resources/assets/customnpcs/lang/ru_RU.lang +++ b/src/main/resources/assets/customnpcs/lang/ru_RU.lang @@ -1,38 +1,39 @@ customnpcs.defaultTextColor=404040 entity.CustomNpc.name=Custom Npc +entity.customnpcs.CustomNpc.name=Custom Npc -itemGroup.cnpcs=CustomNpcs Инструменты -itemGroup.cnpcsw=CustomNpcs Оружие -itemGroup.cnpcsa=CustomNpcs Броня -itemGroup.cnpcsb=CustomNpcs Блоки -itemGroup.cnpcsm=CustomNpcs Разное +itemGroup.cnpcs=CustomNpcs: Инструменты +itemGroup.cnpcsw=CustomNpcs: Оружие +itemGroup.cnpcsa=CustomNpcs: Броня +itemGroup.cnpcsb=CustomNpcs: Блоки +itemGroup.cnpcsm=CustomNpcs: Разное -tile.npcRedstoneBlock.name=Редстоун Блок -tile.npcCarpentyBench.name=Верстак Плотника -tile.npcBloodBlock.name=Блок Крови -tile.npcMailbox.name=Почтовый Ящик -tile.npcLocationBlock.name=Локационный Квестовый Блок +tile.npcRedstoneBlock.name=Редстоун блок +tile.npcCarpentyBench.name=Верстак плотника +tile.npcBloodBlock.name=Блок крови +tile.npcMailbox.name=Почтовый ящик +tile.npcLocationBlock.name=Блок локационного квеста tile.npcBanner.name=Баннер -tile.npcWallBanner.name=Стена Баннер +tile.npcWallBanner.name=Настенный баннер tile.npcChair.name=Стул tile.npcCrate.name=Ящик -tile.npcTallLamp.name=Высокая Лампа -tile.npcWeaponRack.name=Оружейная Стойка -tile.npcCouchWool.name=Шерстяной Диван -tile.npcTable.name=Деревянный Стол -tile.npcCouchWood.name=Деревянный Диван +tile.npcTallLamp.name=Высокая лампа +tile.npcWeaponRack.name=Оружейная стойка +tile.npcCouchWool.name=Шерстяной диван +tile.npcTable.name=Деревянный стол +tile.npcCouchWood.name=Деревянный диван tile.npcLamp.name=Лампа tile.npcCandle.name=Свеча -tile.npcStool.name=Стул +tile.npcStool.name=Табуретка tile.npcBorder.name=Граница -tile.npcBigSign.name=Большой Знак +tile.npcBigSign.name=Большая табличка tile.npcBarrel.name=Бочка tile.npcShelf.name=Полка -tile.npcSign.name=Знак -tile.npcTombstone.name=Надгробная Плита +tile.npcSign.name=Вывеска +tile.npcTombstone.name=Надгробная плита tile.npcCampfire.name=Костёр -tile.npcBeam.name=Луч +tile.npcBeam.name=Брус tile.npcPedestal.name=Пьедестал tile.npcPlaceholder_0.name=Заполнитель tile.npcPlaceholder_1.name=Заполнитель @@ -51,7 +52,7 @@ tile.npcPlaceholder_13.name=Заполнитель tile.npcPlaceholder_14.name=Заполнитель tile.npcPlaceholder_15.name=Заполнитель -gui.deleteConfirm=Вы точно хотите удалить этого NPC? +gui.delete=Вы точно хотите удалить это? gui.add=Добавить gui.remove=Удалить gui.save=Сохранить @@ -62,7 +63,7 @@ gui.time=Время gui.title=Название gui.categories=Категории gui.close=Закрыть -gui.disabled=Отключить +gui.disabled=Выключено gui.increase=Увеличить gui.decrease=Уменьшить gui.day=День @@ -73,32 +74,32 @@ gui.small=Маленький gui.medium=Средний gui.large=Большой gui.type=Тип -gui.retaliate=Месть -gui.panic=Паника +gui.retaliate=Мстить +gui.panic=Паниковать gui.retreat=Отступать gui.nothing=Ничего -gui.break=Ломает -gui.open=Открывает +gui.break=Сломать +gui.open=Открыть gui.darkness=Ночью -gui.sunlight=Днем +gui.sunlight=Днём gui.always=Всегда -gui.untilclose=До закрытия -gui.whenavailable=Движение -gui.ignoreDamage=Игнорировать Урон -gui.minrange=Минимальная Дальность -gui.engagedistance=Дистанция атаки +gui.untilclose=До приближения +gui.whenavailable=В движении +gui.ignoreDamage=Игнориров. урон +gui.ignoreNBT=Игнориров. NBT +gui.minrange=Мин. дальность +gui.engagedistance=Дист. реагирования gui.orbitdistance=Радиус -gui.fightifthisclose=Агрессия при приближении -gui.ambushdistance=Дистанция Засады -gui.whendistant=Когда Растояние -gui.whenhidden=Когда Скрытый -gui.currentFolder=Текущая Папка -gui.play=Играть -gui.selectSound=Выбрать Звуки +gui.fightifthisclose=Атаков. если близко +gui.ambushdistance=Дистанция засады +gui.whendistant=Когда далеко +gui.whenhidden=Когда прячется +gui.currentFolder=Текущая папка +gui.play=Проиграть +gui.selectSound=Выбрать звук gui.selectnpc=Выбор NPC gui.select=Выбор -gui.range=Растояние -gui.name=Имя +gui.range=Расстояние gui.partly=Частично gui.copy=Копировать gui.clear=Очистить @@ -110,221 +111,246 @@ gui.website=Веб-сайт gui.text=Текст gui.detailed=Детали gui.server=Сервер +gui.showmore=Показать больше +gui.update=Обновить +gui.editor=Редактор +gui.playernearby=Игрок рядом +gui.forum=Форум -remote.title=Соседние NPCs +remote.title=Ближайшие NPC remote.reset=Пересоздать remote.tp=Телепортироваться к remote.resetall=Пересоздать всех -remote.freeze=Заморозить +remote.freeze=Заморозить NPC -spawner.entities=Объект +spawner.entities=Сущности spawner.clones=Клоны -spawner.mobspawner=Спавнер Мобов -spawner.mount=Прикрепится к -spawner.mountplayer=Крепление игрока +spawner.clones2=Клоны 2 +spawner.clones3=Клоны 3 +spawner.clones4=Клоны 4 +spawner.mobspawner=Спаунер +spawner.mount=Оседлать +spawner.mountplayer=Оседлать самому -mailbox.name=Почтовый Ящик +spawner.diesafter=Умирает при смерти призв-ых +spawner.posoffset=Смещение позиции +spawner.type=Тип призыва +spawner.all=Все +spawner.random=Случайно +spawner.one=По одному +spawner.despawn=Отзывать призванных при потере цели + +mailbox.name=Почтовый ящик mailbox.sender=Отправитель mailbox.read=Читать mailbox.timesend=%s назад -mailbox.day=День -mailbox.days=Дни -mailbox.hour=Час -mailbox.hours=Часы -mailbox.minute=Минута -mailbox.minutes=Минуты +mailbox.day=день +mailbox.days=дня(-ей) +mailbox.hour=час +mailbox.hours=часа(-ов) +mailbox.minute=минута +mailbox.minutes=минуты(-т) mailbox.username=Никнейм mailbox.subject=Тема mailbox.send=Отправить -mailbox.write=Написать Письмо +mailbox.write=Написать письмо mailbox.succes=Удачно отправлено %s -mailbox.errorUsername=Неизветный Никнейм -mailbox.errorSubject=Поле темы не можеть быть пустым! +mailbox.errorUsername=Неизвестный никнейм +mailbox.errorSubject=Поле темы не может быть пустым mailbox.setup=Установить письмо display.model=Модель display.show=Показывать -display.hide=Спрятать -display.showAttacking=Показывать когда аттакован +display.hide=Прятать +display.showAttacking=Показывать когда атакован display.size=Размер display.texture=Текстура display.cape=Текстура плаща display.overlay=Наложение текстур display.player=Игрок -display.selectTexture=Выбрать Текстуру -display.livingAnimation=Имеет живую анимацию +display.selectTexture=Выбрать текстуру +display.livingAnimation=Есть живая анимация display.visible=Видимый -display.bossbar=Босс жизни +display.bossbar=Полоска жизней босса +display.squareTexture=Квадратная текстура +display.url=Url +display.urlSix=Url64 -inv.minExp=Мин. Опыта +inv.minExp=Мин. опыта inv.maxExp=Макс. опыта -inv.npcInventory=NPC Инвентарь +inv.npcInventory=Инвентарь NPC inv.inventory=Инвентарь -inv.dropChance=Шанс падения +inv.dropChance=Шанс выпадения +inv.auto=Авто-подбор -availability.options=Условия Диалога +availability.options=Настройки доступности availability.always=Всегда availability.after=После availability.before=Перед availability.available=Доступно availability.whenactive=Когда активен -availability.whennotactive=Когда пассивен -availability.selectquest=Выбрать Квест -availability.selectdialog=Выбрать Диалог -availability.selectfaction=Выбрать Фракцию -availability.daytime=День -availability.wholeday=Сутки -availability.night=Во Время ночи -availability.day=Во Время Дня +availability.whennotactive=Когда не активен +availability.selectquest=Выбрать квест +availability.selectdialog=Выбрать диалог +availability.selectfaction=Выбрать фракцию +availability.daytime=Время суток +availability.wholeday=Всё время +availability.night=В течении ночи +availability.day=В течении дня availability.is=Есть availability.isnot=Не есть -availability.minlevel=Опыт Уровень -availability.name=Наличие +availability.minlevel=Уров. опыта +availability.name=Доступность availability.areaNotAvailble=Вы не можете идти туда -availability.permission=У вас недостаточно прав для этого -availability.editIcon=В течение следующих 10 секунд вы можете установить любой значок щелкнув ПКМ +availability.permission=У вас нет прав для этого +availability.editIcon=В течение следующих 10 секунд вы можете установить любую иконку, щёлкнув ПКМ с предметом -spawning.availableBiomes=Доступные Биомы -spawning.spawningBiomes=Биомы Спавна +spawning.availableBiomes=Доступные биомы +spawning.spawningBiomes=Биомы спауна spawning.biomes=Биомы -spawning.weightedChance=Шанс Спавна +spawning.weightedChance=Вероятность спауна role.name=Роль -role.none=Нет Роли -role.trader=Продавец +role.none=Нет роли +role.trader=Торговец role.follower=Последователь -role.bank=Банк -role.transporter=Траспортер +role.bank=Сберегатель +role.transporter=Транспортёр role.mailman=Почтальон -role.marketname=Соответствующее Рыночное название +role.marketname=Связанное название торговли +role.companion=Компаньон trader.insufficient=Недостаточно валюты +trader.sufficient=Достаточно валюты job.name=Работа -job.none=Нет Работы -job.bard=Бард +job.none=Нет работы job.guard=Страж job.healer=Целитель job.bard=Бард -job.itemgiver=Раздатчик ресурсов +job.itemgiver=Раздатчик предметов job.boss=Босс -job.spawner=Спавнер -job.conversation=Разговорщик -job.chunkloader=Носильщик - -spawner.dies=Умирает после спавна -spawner.posoffset=Смещение положения -spawner.type=Вид Спавна -spawner.all=Всё -spawner.random=Рандом -spawner.one=Поодиночке +job.spawner=Призыватель +job.conversation=Собеседник +job.chunkloader=Загрузчик чанка +job.puppet=Марионетка stats.health=Здоровье -stats.aggro=Агро Радиус -stats.meleeproperties=В близи -stats.rangedproperties=Дальняя атака -stats.projectileproperties=Пропорции +stats.aggro=Поле зрения +stats.projectileproperties=Тип снаряда stats.meleestrength=Сила stats.meleerange=Дальность stats.meleespeed=Скорость -stats.accuracy=Точность(%) +stats.accuracy=Точность (%) stats.rangedrange=Дальность -stats.burstspeed=Задержка Огня -stats.mindelay=Минимальная Задержка -stats.maxdelay=Максимальная Задержка -stats.burstcount=Количество Взрывов -stats.shotcount=Количество Выстрелов -stats.walkspeed=Скорость Ходьбы -stats.meleeeffect=Еффект(s) -stats.respawn=Респавн -stats.deadbody=Скрыть Труп -stats.fireimmune=Иммунитет к Огню -stats.candrown=Может плавать -stats.firesound:=МузыкаFX +stats.burstspeed=Скорострельность +stats.mindelay=Мин. задержка +stats.maxdelay=Макс. задержка +stats.burstcount=Кол-во выстрелов +stats.shotcount=Кол-во снарядов +stats.walkspeed=Скорость ходьбы +stats.meleeeffect=Эффект(-ы) +stats.respawn=Возрождение +stats.deadbody=Прятать труп +stats.fireimmune=Иммунитет к огню +stats.candrown=Может утонуть +stats.firesound:=Звуковой эффект stats.creaturetype=Тип существа stats.normal=Нормальный stats.undead=Нежить -stats.arthropod=Членистоногий -stats.nofalldamage=Урон от Падения -stats.meleeproperties=Рукопашная -stats.rangedproperties=Дальнобойная -stats.burninsun=Горит на Солнце -stats.amplify=Усиление -stats.melee=Рукопашная -stats.regenhealth=Реген. Здоровья -stats.combatregen=Реген. в Бою -stats.naturallydespawns=Естевственное исчезание +stats.arthropod=Членистоногое +stats.nofalldamage=Нет урона от паден. +stats.meleeproperties=Настройки ближ. боя +stats.rangedproperties=Настройки дальн. боя +stats.burninsun=Горит на солнце +stats.amplify=Усилен +stats.melee=Ближний бой +stats.disabledamage=Отключить урон +stats.disabletrue=Урон отключен во вкладке "Характеристики" +stats.regenhealth=Реген. здоровья +stats.combatregen=Реген. в бою +stats.naturallydespawns=Естественное исчезновение +stats.aimWhileShooting=Прицелив. при стрельбе +stats.potionImmune=Иммунитет к зельям +stats.attackInvisible=Атаковать невидимых -stats.size=Разм. +stats.size=Размер stats.speed=Скорость -stats.glows=Горит -stats.noglow=Не Горит -stats.hasgravity=Имеет Гравитацию +stats.glows=Светится +stats.noglow=Не светится +stats.hasgravity=Имеет гравитац. stats.explosive=Взрывается stats.rangedeffect=Эффект -stats.trail=Тип -stats.spin=Крутится -stats.stick=Палки -stats.regular=Не Усилен +stats.trail=Тип следа +stats.spin=Вращение +stats.stick=Прилипание +stats.regular=Не усилен stats.amplified=Усилен +stats.explosion=Взрыв ai.standing=Стоит -ai.wandering=Бродит -ai.movingpath=Отмеченный Путь -ai.looping=Петля -ai.backtracking=Патруль +ai.wandering=Блуждает +ai.movingpath=Отмеченный путь +ai.looping=Зациклено +ai.backtracking=В обр. сторону ai.enemyresponse=Если найдет врага -ai.door=Дверь -ai.avoidwater=Избегает воды -ai.return=Вернутся на место -ai.swim=Может Плавать -ai.shelter=Искать убежище +ai.door=Взаимод. с дверью +ai.avoidwater=Избегать воду +ai.return=Возвращ. на место +ai.swim=Может плавать +ai.shelter=Поиск убежища ai.leapattarget=Прыжок на цель ai.sprint=Может бегать -ai.clearlos=Обяз. Видеть цели -ai.indirect=Может Стрелять +ai.clearlos=Должен видеть цель +ai.indirect=Может стрел. косвен. ai.rangemelee=Дальняя атака -ai.tacticalvariant=Такт. Вариант -ai.cobwebAffected=Потерпевшие +ai.tacticalvariant=Тактический вариант +ai.cobwebAffected=Реагир. на паутину ai.movement=Движение -aitactics.rush=Бег -aitactics.stagger=Уворот -aitactics.orbit=Окружить +movement.ground=По земле +movement.flying=Полёт +fly.speed=Скорость полёта +fly.gravity=Гравитация полёта + +aitactics.rush=Натиск +aitactics.stagger=Уклонение +aitactics.orbit=Окружение aitactics.hitandrun=Ударить и бежать aitactics.ambush=Засада aitactics.stalk=Подкрадываться -advanced.idlesound=Живой звук -advanced.angersound=Злой Звук +advanced.idlesound=Звук жизни +advanced.angersound=Звук агрессии advanced.hurtsound=Звук боли advanced.deathsound=Звук смерти advanced.stepsound=Звук шагов advanced.sounds=Звуки -advanced.lines=Роль +advanced.lines=Реплики advanced.night=Ночь -advanced.editingmode=Изменить -advanced.loadday=Загрузите День -advanced.loadnight=Загрузите Ночь -advanced.haspitch=Имеет поле +advanced.editingmode=Режим редактир-ния +advanced.loadday=Загрузить день +advanced.loadnight=Загрузить ночь +advanced.haspitch=Имеет высоту звука -faction.hostiles=Враждебные Фракции -faction.unfriendly=Недружелюбные +faction.hostiles=Враждебные фракции +faction.unfriendly=Недружелюбные faction.neutral=Нейтральные -faction.friendly=Дружелюбны +faction.friendly=Дружелюбные faction.points=Очки -faction.ondeath=После смерти +faction.ondeath=При смерти faction.hidden=Скрытый faction.default=По умолчанию -faction.attackHostile=Атаковать Враждебные Фракции -faction.nostanding=У Вас нет отношений ни с одной Фракцией -faction.options=Настройки Фракций +faction.attackHostile=Атаковать враждебные фракции +faction.defend=Защищать членов фракции +faction.nostanding=У Вас нет отношений ни с одной фракцией +faction.options=Настройки фракций faction.increasepoints=Отношение с %s увеличилось на %s очков faction.decreasepoints=Отношение с %s уменьшилось на %s очков -faction.attacked=Могут быть атакованы мобом +faction.attacked=Атакуемы мобами menu.inventory=Инвентарь -menu.display=Задания +menu.display=Внешний вид menu.stats=Характеристики menu.factions=Фракции menu.ai=ИИ @@ -332,16 +358,17 @@ menu.advanced=Продвинутые menu.global=Глобальные menu.role=Роли -global.banks=Банки -global.transport=Транспортеры +global.banks=Сберегатели +global.transport=Транспортёры global.playerdata=Данные игроков global.recipes=Рецепты -global.naturalspawn=Естевственные спавны +global.naturalspawn=Естественные спауны +global.linked=Связи bank.slot=Слот bank.unlock=Открыть bank.upgrade=Улучшить -bank.upgradeCosts=Стоитмость улучшения +bank.upgradeCosts=Стоимость улучшения bank.unlockCosts=Стоимость открытия follower.waiting=Ждать @@ -349,86 +376,148 @@ follower.following=Следовать follower.hire=Нанять follower.health=Здоровье follower.daysleft=Дней осталось -follower.lastday=Прошло дней -follower.day=День -follower.days=Дней -follower.hireText=Спасибо что наняли меня -follower.farewellText=Срок Договора Истек.Прощай! +follower.lastday=Последн. день +follower.day=день +follower.days=дней +follower.hireText=Спасибо, что наняли меня на +follower.farewellText=Срок договора истек. Прощай! +follower.infiniteDays=Бесконечные дни +follower.guiDisabled=Отключить интерфейс +follower.allowSoulstone=Разрешить камень душ -transporter.travel=Путешествие -transporter.unlock=Транспортировка к %s сейчас заблокирована -transporter.discovered=Доступно если обнаружено +transporter.travel=Отправиться +transporter.unlock=Перемещение к %s теперь разблокировано +transporter.discovered=Доступно когда обнаружено transporter.start=Доступно с самого начала transporter.interaction=Доступно после взаимодействия conversation.delay=Задержка -conversation.line=Реплики +conversation.line=Реплика -bard.jukebox=Музыкальный автомат -bard.background=Играть вокруг -bard.ondistance=На расстоянии -bard.offdistance=Расстояние выключения -bard.hasoff=Выключение на растоянии +bard.jukebox=Проигрывать как в проигрывателе +bard.background=Проигрывать на фоне +bard.ondistance=Расстоян. включения +bard.offdistance=Расстоян. выключения +bard.hasoff=Имеет расстоян. выключения dialog.dialog=Диалог dialog.dialogs=Диалоги -dialog.options=Опции Диалога -dialog.dialogtext=Текст Диалога -dialog.editoption=Изменить Настройки Диалога +dialog.options=Опции диалога +dialog.dialogtext=Текст диалога +dialog.editoption=Изменить опции диалога dialog.optiontype=Тип опции -dialog.selectoption=Выбрать Опцию +dialog.selectoption=Выбрать опцию dialog.quitoption=Опция выхода -dialog.option=Опции Диалога -dialog.roleoption=Опция Роли -dialog.commandoption=Опция Комманд -dialog.commandoptionplayer=Используйте "@dp" для целевого проигрывания этого +dialog.option=Опция диалога +dialog.roleoption=Опция роли +dialog.commandoption=Опция команды +dialog.commandoptionplayer=Используйте "@dp" для выбора игрока, использующего этого +dialog.hideNPC=Прятать NPC +dialog.showWheel=Показывать диалоговое колесо +dialog.disableEsc=Отключить Esc -quest.quest=Задание -quest.quests=Задания -quest.item=Задание на вещь -quest.kill=Задание на убийство -quest.areakill=Зона убийства -quest.dialog=Задание на диалог +quest.quest=Квест +quest.quests=Квесты +quest.item=Предмет +quest.kill=Убийство +quest.areakill=Область убийств +quest.dialog=Диалог quest.location=Локация -quest.completedtext=Завершения Текста -quest.questlogtext=Текст Квеста +quest.completedtext=Текст завершения +quest.questlogtext=Текст квеста quest.complete=Завершить quest.reward=Награда quest.repeatable=Повторяется -quest.mcdaily=Ежедневное -quest.mcweekly=Еженедельное -quest.rldaily=RL День -quest.rlweekly=RL Неделя +quest.mcdaily=Каждый MC день +quest.mcweekly=Каждую MC неделю +quest.rldaily=Каждый реальный день +quest.rlweekly=Каждую реальную неделю quest.instant=Мгновенное завершение -quest.npc=Завершенно npc -quest.next=Следующее Задание +quest.npc=Завершение с NPC +quest.next=Следующий квест quest.found=Найдено quest.notfound=Не найдено -quest.completed=Задание Завершено -quest.newquest=Новое Задание -quest.noquests=У вас нет активных заданий -quest.completewith=Завершенно вместе с %s +quest.completed=Квест завершён +quest.newquest=Новый квест +quest.noquests=У Вас нет активных квестов +quest.completewith=Завершение вместе с %s quest.randomitem=Случайный предмет quest.exp=Опыт -quest.takeitems=Выдать предмет -quest.objectives=Цель +quest.takeitems=Забирать предмет +quest.objectives=Задачи -script.init=Init -script.interact=Инициализация +script.apidoc=API документация +script.apisrc=API исходники + +script.scripts=Сценарии +script.hooks=Хуки +script.loadscript=Загрузить сценарии +script.openfolder=Открыть папку со сценариями +script.init=Инициализация +script.interact=Взаимодействие script.update=Обновление script.console=Консоль script.language=Язык -script.damaged=Поврежденный +script.damaged=Получ. урон script.killed=Убит -script.attack=Атака +script.attack=Атакует script.target=Цель +script.timer=Таймер script.availableScripts=Доступные сценарии -script.loadedScripts=Загруженные сценарит +script.loadedScripts=Загруженные сценарии +script.collide=Столкновение +script.kills=Убивает +script.dialog_closed=Закрыв. диалог + +eventscript.playerevent=События игрока + +playerscript.disabled=Выключено +playerscript.attack=Атакует +playerscript.breakBlock=Ломает блок +playerscript.chat=Чат +playerscript.containerclosed=Закрыв. контейнер +playerscript.containerOpen=Открыв. контейнер +playerscript.damagedEntity=Поврежд. сущность +playerscript.damaged=Получ. урон +playerscript.killed=Убит +playerscript.factionupdate=Репутация фракций +playerscript.init=Инициализация +playerscript.interact=Взаимодействие +playerscript.keyPressed=Клавиша нажата +playerscript.kills=Убийства +playerscript.levelUp=Новый уровень +playerscript.login=Входит +playerscript.logout=Выходит +playerscript.pickUp=Подбор +playerscript.rangedCharge=Натяжение тетивы +playerscript.rangedLaunched=Запуск стрелы +playerscript.toss=Бросает предмет +playerscript.drop=Выпадают предметы +playerscript.tick=Обновление +playerscript.pickupXP=Подбор сферы опыта +playerscript.timer=Таймер +playerscript.mouseClicked=Щелчок мышью +playerscript.startItem=Начин. исп. пред. +playerscript.usingItem=Использует предмет +playerscript.stopItem=Прекр. исп. пред. +playerscript.finishItem=Заканч. исп. пред. +playerscript.playSound=Проигр. звук +playerscript.lightning=Удар молнии +playerscript.fall=Падение +playerscript.jump=Прыжок +playerscript.respawn=Возрождение +playerscript.changedDim=Смена измерения +playerscript.useHoe=Вспахивание +playerscript.sleep=Спит +playerscript.wakeUp=Просыпается +playerscript.fillBucket=Наполняет ведро +playerscript.bonemeal=Удабривает +playerscript.achievement=Достижение item.npcWand.name=Настройщик NPC -item.npcMobCloner.name=Клонер NPC +item.npcMobCloner.name=Клонер мобов item.npcMovingPath.name=Путевод NPC -item.npcMounter.name=Спаунер NPC +item.npcMounter.name=Оседлатель item.npcTeleporter.name=Телепортер item.npcScripter.name=Сценарист @@ -441,269 +530,289 @@ item.npcFrenchHorn.name=Валторна item.npcOcarina.name=Окарина item.npcClarinet.name=Кларнет -item.npcCoinWooden.name=Деревянная Монета -item.npcCoinStone.name=Каменная Монета -item.npcCoinBronze.name=Бронзовая Монета -item.npcCoinIron.name=Железная Монета -item.npcCoinGold.name=Золотая Монета -item.npcCoinDiamond.name=Алмазная Монета -item.npcCoinEmerald.name=Изумрудная Монета +item.npcCoinWooden.name=Деревянная монета +item.npcCoinStone.name=Каменная монета +item.npcCoinBronze.name=Бронзовая монета +item.npcCoinIron.name=Железная монета +item.npcCoinGold.name=Золотая монета +item.npcCoinDiamond.name=Алмазная монета +item.npcCoinEmerald.name=Изумрудная монета -item.npcWoodenGun.name=Деревянный Пистолет -item.npcStoneGun.name=Каменный Пистолет -item.npcIronGun.name=Железный Пистолет -item.npcGoldGun.name=Золотой Пистолет -item.npcDiamondGun.name=Алмазный Пистолет -item.npcBronzeGun.name=Бронзовый Пистолет -item.npcEmeraldGun.name=Изумрудный Пистолет +item.npcWoodenGun.name=Деревянный пистолет +item.npcStoneGun.name=Каменный пистолет +item.npcIronGun.name=Железный пистолет +item.npcGoldGun.name=Золотой пистолет +item.npcDiamondGun.name=Алмазный пистолет +item.npcBronzeGun.name=Бронзовый пистолет +item.npcEmeraldGun.name=Изумрудный пистолет item.npcMachineGun.name=Автомат -item.npcWoodenBullet.name=Деревянная Пуля -item.npcStoneBullet.name=Каменная Пуля -item.npcIronBullet.name=Железная Пуля -item.npcGoldenBullet.name=Золотая Пуля -item.npcDiamondBullet.name=Алмазная Пуля -item.npcBronzeBullet.name=Бронзовая Пуля -item.npcEmeraldBullet.name=Изумрудная Пуля -item.npcBlackBullet.name=Чёрная Пуля +item.npcWoodenBullet.name=Деревянная пуля +item.npcStoneBullet.name=Каменная пуля +item.npcIronBullet.name=Железная пуля +item.npcGoldenBullet.name=Золотая пуля +item.npcDiamondBullet.name=Алмазная пуля +item.npcBronzeBullet.name=Бронзовая пуля +item.npcEmeraldBullet.name=Изумрудная пуля +item.npcBlackBullet.name=Чёрная пуля -item.npcWoodenTrident.name=Деревянный Трезубец -item.npcStoneTrident.name=Каменный Трезубец -item.npcIronTrident.name=Железный Трезубец -item.npcGoldTrident.name=Золотой Трезуебц -item.npcDiamondTrident.name=Алмазный Трезубец -item.npcBronzeTrident.name=Бронзовый Трезубец -item.npcEmeraldTrident.name=Изумрудный Трезубец -item.npcCursedTrident.name=Проклятый Трезубец -item.npcDemonicTrident.name=Демонический Трезубец -item.npcFrostTrident.name=Ледяной Трезубец +item.npcWoodenTrident.name=Деревянный трезубец +item.npcStoneTrident.name=Каменный трезубец +item.npcIronTrident.name=Железный трезубец +item.npcGoldTrident.name=Золотой трезубец +item.npcDiamondTrident.name=Алмазный трезубец +item.npcBronzeTrident.name=Бронзовый трезубец +item.npcEmeraldTrident.name=Изумрудный трезубец +item.npcCursedTrident.name=Проклятый трезубец +item.npcDemonicTrident.name=Демонический трезубец +item.npcFrostTrident.name=Ледяной трезубец +item.npcMithrilTrident.name=Мифриловый трезубец -item.npcNatureSpell.name=Природное Заклинание -item.npcArcaneSpell.name=Тайное Заклинание -item.npcLightningSpell.name=Заклинание Молнии -item.npcIceSpell.name=Ледяное Заклинание -item.npcFireSpell.name=Огненное Заклинание -item.npcDarkSpell.name=Тёмное Заклинание -item.npcHolySpell.name=Святое Заклинание +item.npcNatureSpell.name=Заклинание природы +item.npcArcaneSpell.name=Магическое заклинание +item.npcLightningSpell.name=Заклинание молнии +item.npcIceSpell.name=Заклинание льда +item.npcFireSpell.name=Заклинание огня +item.npcDarkSpell.name=Заклинание тьмы +item.npcHolySpell.name=Священное заклинание item.npcKunai.name=Кунай -item.npcReverseKunai.name=Оратный Кунай -item.npcShuriken.name=Сюрикен -item.npcGiantShuriken.name=Гигантский Сюрикен +item.npcReverseKunai.name=Обратный кунай +item.npcShuriken.name=Сюрикэн +item.npcGiantShuriken.name=Гигантский сюрикэн item.npcKatana.name=Катана item.npcKukri.name=Кукри item.npcGolfClub.name=Клюшка для гольфа -item.npcMagicWand.name=Волшебная Палочка -item.npcChickenSword.name=Цыпленок-мечь +item.npcMagicWand.name=Волшебная палочка +item.npcChickenSword.name=Меч-курица item.npcHandCuffs.name=Наручники -item.npcHammer.name=Молот -item.npcBaseballBat.name=Бейсбольная Бита -item.npcLeadPipe.name=Ведущий трубы -item.npcCleaver.name=Топор Мясника +item.npcHammer.name=Молоток +item.npcBaseballBat.name=Бейсбольная бита +item.npcLeadPipe.name=Свинцовая труба +item.npcCleaver.name=Тесак item.npcSaber.name=Сабля -item.npcHockeyStick.name=Хоккейная Клюшка +item.npcHockeyStick.name=Хоккейная клюшка item.npcSledgeHammer.name=Кувалда -item.npcBrokenBottle.name=Разбитая Бутылка -item.npcCombatKnive.name=Конбинированый клинок +item.npcBrokenBottle.name=Разбитая бутылка +item.npcCombatKnive.name=Боевой нож item.npcLighter.name=Зажигалка -item.npcBatton.name=Баттон -item.npcGunChainsaw.name=Автомат-Бензопила +item.npcBatton.name=Полицейская дубинка +item.npcGunChainsaw.name=Автомат-бензопила item.npcRapier.name=Рапира -item.npcCrowbar.name=Лом -item.npcPipeWrench.name=Ключь для труб +item.npcCrowbar.name=Монтировка +item.npcPipeWrench.name=Разводной ключ item.npcWrench.name=Гаечный ключ -item.npcSwissArmyKnife.name=Швейцарский Армейский Нож -item.npcLeafBlade.name=Листовая пластинка +item.npcSwissArmyKnife.name=Швейцарский армейский нож +item.npcLeafBlade.name=Лиственный клинок -item.npcWoodenShield.name=Круглый Деревянный Щит -item.npcStoneShield.name=Круглый Каменный Щит -item.npcIronShield.name=Круглый Железный Щит -item.npcGoldenShield.name=Круглый Золотой Щит -item.npcDiaShield.name=Круглый Алмазный Щит -item.npcBronzeShield.name=Круглый Бронзовый Щит -item.npcEmeraldShield.name=Круглый Изумрудный Щит -item.npcDemonicShield.name=Демонический Щит -item.npcFrostShield.name=Ледяной Щит -item.npcFullWoodenShield.name=Деревянный Щит -item.npcFullStoneShield.name=Каменный Щит -item.npcFullIronShield.name=Железный Щит -item.npcFullGoldenShield.name=Золотой Щит -item.npcFullDiaShield.name=Алмазный Щит -item.npcFullBronzeShield.name=Бронзовый Щит -item.npcFullEmeraldShield.name=Изумрудный Щит +item.npcWoodenShield.name=Круглый деревянный щит +item.npcStoneShield.name=Круглый каменный щит +item.npcIronShield.name=Круглый железный щит +item.npcGoldenShield.name=Круглый золотой щит +item.npcDiaShield.name=Круглый алмазный щит +item.npcBronzeShield.name=Круглый бронзовый щит +item.npcEmeraldShield.name=Круглый изумрудный щит +item.npcDemonicShield.name=Демонический щит +item.npcFrostShield.name=Ледяной щит +item.npcMithrilShield.name=Мифриловый щит +item.npcFullWoodenShield.name=Деревянный щит +item.npcFullStoneShield.name=Каменный щит +item.npcFullIronShield.name=Железный щит +item.npcFullGoldenShield.name=Золотой щит +item.npcFullDiaShield.name=Алмазный щит +item.npcFullBronzeShield.name=Бронзовый щит +item.npcFullEmeraldShield.name=Изумрудный щит -item.npcTowerShield.name=Стальной Щит "Башня" -item.npcCryscentShield.name=Стальной Щит "Полумесяц" -item.npcScutumShield.name=Стальной Щит "Щиток" -item.npcHeaterShield.name=Стальной Щит "Нагреватель" +item.npcTowerShield.name=Башенный щит +item.npcCryscentShield.name=Щит полумесяц +item.npcScutumShield.name=Щит скутум +item.npcHeaterShield.name=Щит экю -item.npcWoodenSpear.name=Деревянное Копье -item.npcStoneSpear.name=Каменное Копье -item.npcIronSpear.name=Железное Копье -item.npcGoldenSpear.name=Золотое Копье -item.npcDiamondSpear.name=Алмазное Копье -item.npcBronzeSpear.name=Бронзовое Копье -item.npcEmeraldSpear.name=Изумрудное Копье -item.npcDemonicSpear.name=Демоническое Копье -item.npcFrostSpear.name=Ледяное Копье +item.npcWoodenSpear.name=Деревянное копьё +item.npcStoneSpear.name=Каменное копьё +item.npcIronSpear.name=Железное копьё +item.npcGoldenSpear.name=Золотое копьё +item.npcDiamondSpear.name=Алмазное копьё +item.npcBronzeSpear.name=Бронзовое копьё +item.npcEmeraldSpear.name=Изумрудное копьё +item.npcDemonicSpear.name=Демоническое копьё +item.npcFrostSpear.name=Ледяное копьё +item.npcMithrilSpear.name=Мифриловое копьё -item.npcWoodenBattleAxe.name=Деревянный Боевой Топор -item.npcStoneBattleAxe.name=Каменный Боевой Топор -item.npcIronBattleAxe.name=Железный Боевой Топор -item.npcGoldenBattleAxe.name=Золотой Боевой Топор -item.npcDiamondBattleAxe.name=Алмазный Боевой Топор -item.npcBronzeBattleAxe.name=Бронзовый Боевой Топор -item.npcEmeraldBattleAxe.name=Изумрудный Боевой Топор -item.npcDemonicBattleAxe.name=Демонический Боевой Топор -item.npcFrostBattleAxe.name=Ледяной Боевой Топор +item.npcWoodenBattleAxe.name=Деревянный боевой топор +item.npcStoneBattleAxe.name=Каменный боевой топор +item.npcIronBattleAxe.name=Железный боевой топор +item.npcGoldenBattleAxe.name=Золотой боевой топор +item.npcDiamondBattleAxe.name=Алмазный боевой топор +item.npcBronzeBattleAxe.name=Бронзовый боевой топор +item.npcEmeraldBattleAxe.name=Изумрудный боевой топор +item.npcDemonicBattleAxe.name=Демонический боевой топор +item.npcFrostBattleAxe.name=Ледяной боевой топор +item.npcMithrilBattleAxe.name=Мифриловый боевой топор -item.npcWoodenMace.name=Деревянная Булава -item.npcStoneMace.name=Каменная Булава -item.npcIronMace.name=Железная Булава -item.npcGoldenMace.name=Золотая Булава -item.npcDiamondMace.name=Алмазная Булава -item.npcBronzeMace.name=Бронзовая Булава -item.npcEmeraldMace.name=Изумрудная Булава -item.npcDemonicMace.name=Демоническая Булава -item.npcFrostMace.name=Ледяная Булава +item.npcWoodenMace.name=Деревянная булава +item.npcStoneMace.name=Каменная булава +item.npcIronMace.name=Железная булава +item.npcGoldenMace.name=Золотая булава +item.npcDiamondMace.name=Алмазная булава +item.npcBronzeMace.name=Бронзовая булава +item.npcEmeraldMace.name=Изумрудная булава +item.npcDemonicMace.name=Демоническая булава +item.npcFrostMace.name=Ледяная булава +item.npcMithrilMace.name=Мифриловая булава -item.npcWoodenDagger.name=Деревянный Кинжал -item.npcStoneDagger.name=Каменный Кинжал -item.npcIronDagger.name=Железный Кинжал -item.npcGoldenDagger.name=Золотой Кинжал -item.npcDiamondDagger.name=Алмазный Кинжал -item.npcBronzeDagger.name=Бронзовый Кинжал -item.npcEmeraldDagger.name=Изумрудный Кинжал -item.npcDemonicDagger.name=Демонический Кинжал -item.npcFrostDagger.name=Ледяной Кинжал -item.npcWoodenReversedDagger.name=Обратный Деревянный Кинжал -item.npcStoneReversedDagger.name=Обратный Каменный Кинжал -item.npcIronReversedDagger.name=Обратный Железный Кинжал -item.npcGoldenReversedDagger.name=Обратный Золотой Кинжал -item.npcDiamondReversedDagger.name=Обратный Алмазный Кинжал -item.npcBronzeReversedDagger.name=Обратный Бронзовый Кинжал -item.npcEmeraldReversedDagger.name=Обратный Изумрудный Кинжал -item.npcDemonicReversedDagger.name=Обратный Демонический Кинжал -item.npcFrostReversedDagger.name=Обратный Ледяной Кинжал +item.npcWoodenDagger.name=Деревянный кинжал +item.npcStoneDagger.name=Каменный кинжал +item.npcIronDagger.name=Железный кинжал +item.npcGoldenDagger.name=Золотой кинжал +item.npcDiamondDagger.name=Алмазный кинжал +item.npcBronzeDagger.name=Бронзовый кинжал +item.npcEmeraldDagger.name=Изумрудный кинжал +item.npcDemonicDagger.name=Демонический кинжал +item.npcFrostDagger.name=Ледяной кинжал +item.npcMithrilDagger.name=Мифриловый кинжал +item.npcWoodenReversedDagger.name=Обратный деревянный кинжал +item.npcStoneReversedDagger.name=Обратный каменный кинжал +item.npcIronReversedDagger.name=Обратный железный кинжал +item.npcGoldenReversedDagger.name=Обратный золотой кинжал +item.npcDiamondReversedDagger.name=Обратный алмазный кинжал +item.npcBronzeReversedDagger.name=Обратный бронзовый кинжал +item.npcEmeraldReversedDagger.name=Обратный изумрудный кинжал +item.npcDemonicReversedDagger.name=Обратный демонический кинжал +item.npcFrostReversedDagger.name=Обратный ледяной кинжал +item.npcMithrilReversedDagger.name=Обратный мифриловый кинжал -item.npcWoodenStaff.name=Деревянный Посох -item.npcStoneStaff.name=Каменный Посох -item.npcIronStaff.name=Железный Посох -item.npcGoldenStaff.name=Золотой Посох -item.npcDiamondStaff.name=Алмазный Посох -item.npcBronzeStaff.name=Бронзовый Посох -item.npcEmeraldStaff.name=Изумрудный Посох -item.npcElementalStaff.name=Элементальный Посох -item.npcDemonicStaff.name=Демонический Посох -item.npcFrostStaff.name=Ледяной Посох +item.npcWoodenStaff.name=Деревянный посох +item.npcStoneStaff.name=Каменный посох +item.npcIronStaff.name=Железный посох +item.npcGoldenStaff.name=Золотой посох +item.npcDiamondStaff.name=Алмазный посох +item.npcBronzeStaff.name=Бронзовый посох +item.npcEmeraldStaff.name=Изумрудный посох +item.npcElementalStaff.name=Элементальный посох +item.npcDemonicStaff.name=Демонический посох +item.npcFrostStaff.name=Ледяной посох +item.npcMithrilStaff.name=Мифриловый посох -item.npcWoodenScythe.name=Деревянная Коса -item.npcStoneScythe.name=Каменная Коса -item.npcIronScythe.name=Железная Коса -item.npcGoldenScythe.name=Золотая Коса -item.npcBronzeScythe.name=Бронзовая Коса -item.npcDiamondScythe.name=Алмазная Коса -item.npcEmeraldScythe.name=Изумрудная Коса -item.npcDemonicScythe.name=Демоническая Коса -item.npcFrostScythe.name=Ледяная Коса +item.npcWoodenScythe.name=Деревянная коса +item.npcStoneScythe.name=Каменная коса +item.npcIronScythe.name=Железная коса +item.npcGoldenScythe.name=Золотая коса +item.npcBronzeScythe.name=Бронзовая коса +item.npcDiamondScythe.name=Алмазная коса +item.npcEmeraldScythe.name=Изумрудная коса +item.npcDemonicScythe.name=Демоническая коса +item.npcFrostScythe.name=Ледяная коса +item.npcMithrilScythe.name=Мифриловая коса -item.npcWoodenGlaive.name=Деревянный Меч -item.npcStoneGlaive.name=Каменный Меч -item.npcIronGlaive.name=Железный Меч -item.npcGoldenGlaive.name=Золотой Меч -item.npcDiamondGlaive.name=Алмазный Меч -item.npcBronzeGlaive.name=Бронзовый Меч -item.npcEmeraldGlaive.name=Изумрудный Меч -item.npcDemonicGlaive.name=Демонический Меч -item.npcFrostGlaive.name=Ледяной Меч +item.npcWoodenGlaive.name=Деревянный двухсторонний меч +item.npcStoneGlaive.name=Каменный двухсторонний меч +item.npcIronGlaive.name=Железный двухсторонний меч +item.npcGoldenGlaive.name=Золотой двухсторонний меч +item.npcDiamondGlaive.name=Алмазный двухсторонний меч +item.npcBronzeGlaive.name=Бронзовый двухсторонний меч +item.npcEmeraldGlaive.name=Изумрудный двухсторонний меч +item.npcDemonicGlaive.name=Демонический двухсторонний меч +item.npcFrostGlaive.name=Ледяной двухсторонний меч +item.npcMithrilGlaive.name=Мифриловый двухсторонний меч item.npcCowleatherHead.name=Шлем из кожи коровы item.npcCowleatherChest.name=Нагрудник из кожи коровы item.npcCowleatherLegs.name=Поножи из кожи коровы item.npcCowleatherBoots.name=Ботинки из кожи коровы -item.npcNanorumHead.name=Шлем Рыцаря -item.npcNanorumChest.name=Нагрудник Рыцаря -item.npcNanorumLegs.name=Поножи Рыцаря -item.npcNanorumBoots.name=Ботинки Рыцаря +item.npcNanorumHead.name=Шлем рыцаря +item.npcNanorumChest.name=Нагрудник рыцаря +item.npcNanorumLegs.name=Поножи рыцаря +item.npcNanorumBoots.name=Ботинки рыцаря -item.npcTacticalHead.name=Тактический Шлем -item.npcTacticalChest.name=Тактический Жилет +item.npcTacticalHead.name=Тактический шлем +item.npcTacticalChest.name=Тактический жилет -item.npcFullLeatherHead.name=Полный Кожаный Шлем -item.npcFullLeatherChest.name=Полный Кожаный Нагрудник +item.npcFullLeatherHead.name=Полный кожаный шлем +item.npcFullLeatherChest.name=Полный кожаный нагрудник -item.npcFullIronHead.name=Полный Железный Шлем -item.npcFullIronChest.name=Полный Железный Нагрудник +item.npcFullIronHead.name=Полный железный шлем +item.npcFullIronChest.name=Полный железный нагрудник -item.npcFullGoldHead.name=Полный Золотой Шлем -item.npcFullGoldChest.name=Полный Золотой Нагрудник +item.npcFullGoldHead.name=Полный золотой шлем +item.npcFullGoldChest.name=Полный золотой нагрудник -item.npcFullDiamondHead.name=Полный Алмазный Шлем -item.npcFullDiamondChest.name=Полный Алмазный Нагрудник +item.npcFullDiamondHead.name=Полный алмазный шлем +item.npcFullDiamondChest.name=Полный алмазный нагрудник -item.npcFullBronzeHead.name=Полный Бронзовый Шлем -item.npcFullBronzeChest.name=Полный Бронзовый Нагрудник -item.npcFullBronzeLeggings.name=Полные Бронзовые Поножи -item.npcFullBronzeBoots.name=Полные Бронзовые Ботинки +item.npcFullBronzeHead.name=Полный бронзовый шлем +item.npcFullBronzeChest.name=Полный бронзовый нагрудник +item.npcFullBronzeLeggings.name=Полные бронзовые поножи +item.npcFullBronzeBoots.name=Полные бронзовые ботинки -item.npcFullWoodenHead.name=Полный Деревянный Шлем -item.npcFullWoodenChest.name=Полный Деревянный Нагрудник -item.npcFullWoodenLeggings.name=Полный Деревянные Поножи -item.npcFullWoodenBoots.name=Полный Деревянные Ботинки +item.npcFullWoodenHead.name=Полный деревянный шлем +item.npcFullWoodenChest.name=Полный деревянный нагрудник +item.npcFullWoodenLeggings.name=Полные деревянные поножи +item.npcFullWoodenBoots.name=Полные деревянные ботинки -item.npcTuxedoChest.name=Смокинг(Нагрудник) -item.npcTuxedoPants.name=Смокинг(Поножи) -item.npcTuxedoBottom.name=Смокинг(Плащ) +item.npcTuxedoChest.name=Пиджак смокинга +item.npcTuxedoPants.name=Брюки смокинга +item.npcTuxedoBottom.name=Плащ смокинга -item.npcWizardHead.name=Шлем Волшебника -item.npcWizardChest.name=Нагрудник Волшебника -item.npcWizardPants.name=Поножи Волшебника +item.npcWizardHead.name=Капюшон волшебника +item.npcWizardChest.name=Роба волшебника +item.npcWizardPants.name=Шаровары волшебника -item.npcAssassinHead.name=Шлем Ассасина -item.npcAssassinChest.name=Нагрудник Ассасина -item.npcAssassinLeggings.name=Поножи Ассасина -item.npcAssassinBoots.name=Ботинки Ассасина +item.npcAssassinHead.name=Капюшон ассасина +item.npcAssassinChest.name=Нагрудник ассасина +item.npcAssassinLeggings.name=Штаны ассасина +item.npcAssassinBoots.name=Ботинки ассасина -item.npcSoldierHead.name=Шлем Солдата -item.npcSoldierChest.name=Нагрудник Солдата -item.npcSoldierLegs.name=Поножи Солдата -item.npcSoldierBottom.name=Плащ Солдата +item.npcSoldierHead.name=Шлем солдата +item.npcSoldierChest.name=Нагрудник солдата +item.npcSoldierLegs.name=Штаны солдата +item.npcSoldierBottom.name=Плащ солдата -item.npcX407Head.name=X407 Прототипный Шлема -item.npcX407Chest.name=X407 Прототип Нагрудника -item.npcX407Legs.name=X407 Прототип Поножи -item.npcX407Boots.name=X407 Прототип Ботинок +item.npcX407Head.name=Прототип X407 шлема +item.npcX407Chest.name=Прототип X407 нагрудника +item.npcX407Legs.name=Прототип X407 штанов +item.npcX407Boots.name=Прототип X407 ботинок -item.npcCommissarHead.name=Шлем Комиссара -item.npcCommissarChest.name=Нагрудник Комиссара -item.npcCommissarLegs.name=Поножи Комиссара -item.npcCommissarBottom.name=Плащ Комиссара +item.npcMithrilHead.name=Мифриловый шлем +item.npcMithrilChest.name=Мифриловый нагрудник +item.npcMithrilLegs.name=Мифриловые поножи +item.npcMithrilBoots.name=Мифриловые ботинки -item.npcInfantryHelmet.name=Шлем Пехоты -item.npcOfficerChest.name=Нагрудник Офицера +item.npcDemonicHead.name=Демонический шлем +item.npcDemonicChest.name=Демонический нагрудник +item.npcDemonicLegs.name=Демонические поножи +item.npcDemonicBoots.name=Демонические ботинки -item.npcCrown.name=Корона -item.npcCrown2.name=Корона -item.npcPaperCrown.name=Бумажная Корона +item.npcCommissarHead.name=Кепка комиссара +item.npcCommissarChest.name=Нагрудник комиссара +item.npcCommissarLegs.name=Штаны комиссара +item.npcCommissarBottom.name=Плащ комиссара -item.npcNinjaHead.name=Шлем Ниндзя -item.npcNinjaChest.name=Нагрудник Ниндзя -item.npcNinjaPants.name=Поножи Ниндзя +item.npcInfantryHelmet.name=Шлем пехотинца +item.npcOfficerChest.name=Нагрудник офицера -item.npcFullEmeraldHead.name=Полный Изумрудный Шлем -item.npcFullEmeraldChest.name=Полный Изумрудный Нагрудник -item.npcFullEmeraldLeggings.name=Полные Изумрудные Поножи -item.npcFullEmeraldBoots.name=Полные Изумрудные Ботинки +item.npcCrown.name=Драгоценная корона +item.npcCrown2.name=Золотая корона +item.npcPaperCrown.name=Бумажная корона + +item.npcNinjaHead.name=Маска ниндзя +item.npcNinjaChest.name=Нагрудник ниндзя +item.npcNinjaPants.name=Штаны ниндзя + +item.npcFullEmeraldHead.name=Полный изумрудный шлем +item.npcFullEmeraldChest.name=Полный изумрудный нагрудник +item.npcFullEmeraldLeggings.name=Полные изумрудные поножи +item.npcFullEmeraldBoots.name=Полные изумрудные ботинки item.npcOrb.name=Сфера -item.npcBrokenOrb.name=Разбитая Сфера +item.npcBrokenOrb.name=Разбитая сфера item.npcMana.name=Мана -item.npcNinjaClaw.name=Коготь Ниндзя -item.npcSteelClaw.name=Стальной Коготь -item.npcBearClaw.name=Медвежий Коготь +item.npcNinjaClaw.name=Коготь ниндзя +item.npcSteelClaw.name=Стальной коготь +item.npcBearClaw.name=Медвежий коготь item.npcKatar.name=Катар item.npcLetter.name=Письмо @@ -711,93 +820,180 @@ item.npcPlans.name=Конверт item.npcSatchel.name=Мешок item.npcBag.name=Сумка item.npcCrystal.name=Кристалл -item.npcSeveredEar.name=Серверированая Уха +item.npcSeveredEar.name=Отрезанное ухо item.npcPhone.name=Телефон -item.npcBanditMask.name=Бандитская Маска -item.npcBrokenArrow.name=Сломаная Стрела -item.npcEarthElement.name=Земляной Элемент -item.npcWaterElement.name=Водяной Элемент -item.npcFireElement.name=Огненный Элемент -item.npcAirElement.name=Воздушный Элемент -item.npcCarKey.name=Автомобильные ключи +item.npcBanditMask.name=Маска бандита +item.npcBrokenArrow.name=Сломанная стрела +item.npcEarthElement.name=Элемент земли +item.npcWaterElement.name=Элемент воды +item.npcFireElement.name=Элемент огня +item.npcAirElement.name=Элемент воздуха +item.npcCarKey.name=Автомобильный ключ item.npcKey.name=Ключ item.npcKey2.name=Ключ item.npcPendant.name=Кулон -item.npcBlueprint.name=План +item.npcBlueprint.name=Чертёж item.npcRing.name=Кольцо item.npcSkull.name=Череп item.npcSaphire.name=Сапфир -item.npcAmethyst.name=Аметис +item.npcAmethyst.name=Аметист item.npcRuby.name=Рубин -item.npcBronzeIngot.name=Бронзовый Слиток -item.npcDemonicIngot.name=Демонический Слиток +item.npcBronzeIngot.name=Бронзовый слиток +item.npcDemonicIngot.name=Демонический слиток +item.npcMithrilIngot.name=Мифриловый слиток -item.npcMacuahuitl.name=Оружие Ацтеков +item.npcMacuahuitl.name=Меч Macuahuitl item.npcBoStaff.name=Посох Бо -item.npcSaiBlade.name=Лезвие Сай +item.npcSaiBlade.name=Сай item.npcCrossbow.name=Арбалет -item.npcCrossBolt.name=Арбалетный Болт +item.npcCrossBolt.name=Болт арбалета item.npcSlingshot.name=Рогатка item.npcMusket.name=Мушкет -item.npcExcalibur.name=Екскалибур +item.npcExcalibur.name=Экскалибур -item.npcBronzeSword.name=Бронзовый Меч -item.npcEmeraldSword.name=Изумрудный Меч -item.npcDemonicSword.name=Демонический Меч -item.npcFrostSword.name=Ледяной Меч +item.npcBronzeSword.name=Бронзовый меч +item.npcEmeraldSword.name=Изумрудный меч +item.npcDemonicSword.name=Демонический меч +item.npcFrostSword.name=Ледяной меч +item.npcMithrilSword.name=Мифриловый меч -item.npcAncientCoin.name=Древняя Монета -item.npcAncientScroll.name=Древний Свиток +item.npcAncientCoin.name=Древняя монета +item.npcAncientScroll.name=Древний свиток item.npcArtifact.name=Артефакт item.npcLocket.name=Медальон -item.npcSilk.name=Шелк -item.npcStatuette.name=Статуетка +item.npcSilk.name=Шёлк +item.npcStatuette.name=Статуэтка item.npcTablet.name=Скрижаль -item.npcWoodenHalberd.name=Деревянная Алебарда -item.npcStoneHalberd.name=Каменная Алебарда -item.npcIronHalberd.name=Железная Алебарда -item.npcGoldenHalberd.name=Золотая Алебарда -item.npcDiamondHalberd.name=Алмазная Алебарда -item.npcBronzeHalberd.name=Бронзовая Алебарда -item.npcEmeraldHalberd.name=Изумрудная Алебарда -item.npcCursedHalberd.name=Проклятая Алебарда -item.npcDemonicHalberd.name=Демоническая Алебарда -item.npcFrostHalberd.name=Ледяная Алебарда +item.npcWoodenHalberd.name=Деревянная алебарда +item.npcStoneHalberd.name=Каменная алебарда +item.npcIronHalberd.name=Железная алебарда +item.npcGoldenHalberd.name=Золотая алебарда +item.npcDiamondHalberd.name=Алмазная алебарда +item.npcBronzeHalberd.name=Бронзовая алебарда +item.npcEmeraldHalberd.name=Изумрудная алебарда +item.npcCursedHalberd.name=Проклятая алебарда +item.npcDemonicHalberd.name=Демоническая алебарда +item.npcFrostHalberd.name=Ледяная алебарда +item.npcMithrilHalberd.name=Мифриловая алебарда -item.npcWoodenWarhammer.name=Деревянный Боевой Молот -item.npcStoneWarhammer.name=Каменный Боевой Молот -item.npcIronWarhammer.name=Железный Боевой Молот -item.npcGoldenWarhammer.name=Золотой Боевой Молот -item.npcDiamondWarhammer.name=Алмазный Боевой Молот -item.npcBronzeWarhammer.name=Бронзовый Боевой Молот -item.npcEmeraldWarhammer.name=Изумрудный Боевой Молот -item.npcCursedWarhammer.name=Проклятый Боевой Молот -item.npcDemonicWarhammer.name=Демонический Боевой Молот -item.npcFrostWarhammer.name=Ледяной Боевой Молот +item.npcWoodenWarhammer.name=Деревянный боевой молот +item.npcStoneWarhammer.name=Каменный боевой молот +item.npcIronWarhammer.name=Железный боевой молот +item.npcGoldenWarhammer.name=Золотой боевой молот +item.npcDiamondWarhammer.name=Алмазный боевой молот +item.npcBronzeWarhammer.name=Бронзовый боевой молот +item.npcEmeraldWarhammer.name=Изумрудный боевой молот +item.npcCursedWarhammer.name=Проклятый боевой молот +item.npcDemonicWarhammer.name=Демонический боевой молот +item.npcFrostWarhammer.name=Ледяной боевой молот +item.npcMithrilWarhammer.name=Мифриловый боевой молот -item.npcChainSkirt.name=Кольчужная Юбка -item.npcLeatherSkirt.name=Кожаный Юбка -item.npcGoldSkirt.name=Золотой Юбка -item.npcIronSkirt.name=Железная Юбка -item.npcDiamondSkirt.name=Алмазная Юбка +item.npcChainSkirt.name=Кольчужная юбка +item.npcLeatherSkirt.name=Кожаная юбка +item.npcGoldSkirt.name=Золотая юбка +item.npcIronSkirt.name=Железная юбка +item.npcDiamondSkirt.name=Алмазная юбка +item.npcEmeraldSkirt.name=Изумрудная юбка +item.npcBronzeSkirt.name=Бронзовая юбка +item.npcDemonicSkirt.name=Демоническая юбка +item.npcMithrilSkirt.name=Мифриловая юбка + +item.npcWoodenBroadsword.name=Деревянный палаш +item.npcStoneBroadsword.name=Каменный палаш +item.npcIronBroadsword.name=Железный палаш +item.npcGoldenBroadsword.name=Золотой палаш +item.npcDiamondBroadsword.name=Алмазный палаш +item.npcBronzeBroadsword.name=Бронзовый палаш +item.npcEmeraldBroadsword.name=Изумрудный палаш +item.npcCursedBroadsword.name=Проклятый палаш +item.npcDemonicBroadsword.name=Демонический палаш +item.npcFrostBroadsword.name=Ледяной палаш +item.npcMithrilBroadsword.name=Мифриловый палаш + +item.npcSoulstoneEmpty.name=Пустой камень душ +item.npcSoulstoneFilled.name=Заполненный камень душ + +item.npcHeart.name=Сердце +item.npcMoney.name=Деньги +item.npcNecklace.name=Ожерелье +item.npcUsbStick.name=USB-Флешка enchantment.damage=Урон enchantment.confusion=Смятение -enchantment.infinite=Бесконечный -enchantment.poison=Зелье +enchantment.infinite=Бесконечность (CNPC) +enchantment.poison=Отравление -item.npcWoodenBroadsword.name=Деревянный Палаш -item.npcStoneBroadsword.name=Каменный Палаш -item.npcIronBroadsword.name=Делезный Палаш -item.npcGoldenBroadsword.name=Золотой Палаш -item.npcDiamondBroadsword.name=Алмазный Палаш -item.npcBronzeBroadsword.name=Бронзовый Палаш -item.npcEmeraldBroadsword.name=Изумрудный Палаш -item.npcCursedBroadsword.name=Проклятый Палаш -item.npcDemonicBroadsword.name=Демонический Палаш -item.npcFrostBroadsword.name=Ледяной Палаш +movement.name=Движение +movement.type=Тип перемещения +movement.wanderinteract=Взаимодействовать с NPC +movement.sitting=Сидит +movement.lying=Лежит +movement.sneaking=Крадётся +movement.dancing=Танцует +movement.aiming=Целится +movement.animation=Анимация +movement.rotation=Вращение +movement.body=Тело +movement.manual=В ручную +movement.stalking=Слежение +movement.head=Голова +movement.pauses=Паузы +movement.stopinteract=Останав. при взаимодейст. +movement.crawling=Ползает +movement.hug=Обнимает -#Made by nextcube.ru -#Specifically Ice Troll \ No newline at end of file +model.head=Голова +model.rarm=П. рука +model.larm=Л. рука +model.arms=Руки +model.body=Туловище +model.lleg=Л. нога +model.rleg=П. нога +model.legs=Ноги +model.scale=Размер +model.load=Загрузить модель +model.save=Сохранить модель + +puppet.standing=Пока стоит +puppet.walking=Пока ходит +puppet.attacking=Пока атакует + +guard.creepers=Атаковать криперов +guard.animals=Атаковать животных +guard.mobs=Атаковать монстров +guard.currentTargets=Текущие цели +guard.availableTargets=Доступные цели +guard.specifictargets=Конкретные цели + +companion.baby=Ребёнок +companion.child=Дитя +companion.teenager=Подросток +companion.adult=Юноша +companion.fullgrown=Взрослый +companion.age=Возраст +companion.stage=Стадия +companion.owner=Владелец +companion.strength=Сила +companion.talent=Талант +companion.level=Уровень + +markov.generic.name=Универсальный генератор +markov.ancientGreek.name=Древнегреческий +markov.aztec.name=Ацтекский +markov.classicCNPCs.name=Классический Custom NPC +markov.japanese.name=Японский +markov.oldNorse.name=Древнескандинавский +markov.roman.name=Римский (Латынь) +markov.sami.name=Саамский (Саам) +markov.slavic.name=Древнепольский +markov.welsh.name=Бретонский (Валлийский) +markov.spanish.name=Испанский (Латинский) + +markov.gender.name=Пол +markov.gender.either=Любой +markov.gender.female=Женский +markov.gender.male=Мужской + +markov.generate=Сгенерировать From 1487003192a8a7bc06c2b459ba6592422c9a6e22 Mon Sep 17 00:00:00 2001 From: StrangeMan1580 <86133978+StrangeMan1580@users.noreply.github.com> Date: Sat, 9 Apr 2022 16:46:44 +0300 Subject: [PATCH 02/75] Update ru_RU.lang Retranslation from scratch From b309738c0b1fe851a6a2d6cd453a8ab49352641c Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Mon, 2 May 2022 01:41:43 -0500 Subject: [PATCH 03/75] Fixed swingHand() function for ScriptPlayer --- src/main/java/noppes/npcs/NoppesUtilPlayer.java | 4 ++++ src/main/java/noppes/npcs/client/PacketHandlerClient.java | 3 +++ src/main/java/noppes/npcs/constants/EnumPacketClient.java | 3 +-- src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java | 4 ++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/NoppesUtilPlayer.java b/src/main/java/noppes/npcs/NoppesUtilPlayer.java index cb7f2e7f6..47145ef70 100644 --- a/src/main/java/noppes/npcs/NoppesUtilPlayer.java +++ b/src/main/java/noppes/npcs/NoppesUtilPlayer.java @@ -124,6 +124,10 @@ public class NoppesUtilPlayer { } player.worldObj.updateEntityWithOptionalForce(player, false); } + + public static void swingPlayerArm(EntityPlayerMP player){ + Server.sendData(player, EnumPacketClient.SWING_PLAYER_ARM); + } private static void followerBuy(RoleFollower role,IInventory currencyInv,EntityPlayerMP player, EntityNPCInterface npc){ ItemStack currency = currencyInv.getStackInSlot(0); diff --git a/src/main/java/noppes/npcs/client/PacketHandlerClient.java b/src/main/java/noppes/npcs/client/PacketHandlerClient.java index ea6c4891c..d3cfca705 100644 --- a/src/main/java/noppes/npcs/client/PacketHandlerClient.java +++ b/src/main/java/noppes/npcs/client/PacketHandlerClient.java @@ -270,5 +270,8 @@ public class PacketHandlerClient extends PacketHandlerServer{ int id = buffer.readInt(); Client.customOverlays.remove(id); } + else if(type == EnumPacketClient.SWING_PLAYER_ARM){ + Minecraft.getMinecraft().thePlayer.swingItem(); + } } } diff --git a/src/main/java/noppes/npcs/constants/EnumPacketClient.java b/src/main/java/noppes/npcs/constants/EnumPacketClient.java index 243674a9a..8587226e9 100644 --- a/src/main/java/noppes/npcs/constants/EnumPacketClient.java +++ b/src/main/java/noppes/npcs/constants/EnumPacketClient.java @@ -1,6 +1,5 @@ package noppes.npcs.constants; public enum EnumPacketClient { - CHAT, MESSAGE, SYNCRECIPES_ADD, SYNCRECIPES_WORKBENCH, DIALOG, QUEST_COMPLETION, EDIT_NPC, PLAY_SOUND, PLAY_MUSIC, UPDATE_NPC, ROLE, GUI, SCRIPTED_PARTICLE, PARTICLE, DELETE_NPC, SCROLL_LIST, SCROLL_DATA, SCROLL_DATA_PART, SCROLL_SELECTED, GUI_REDSTONE, GUI_WAYPOINT, GUI_DATA, GUI_ERROR, GUI_CLOSE, VILLAGER_LIST, CHATBUBBLE, SYNCRECIPES_CARPENTRYBENCH, CLONE, OPEN_BOOK, DIALOG_DUMMY, CONFIG, ISGUIOPEN, OVERLAY_DATA, OVERLAY_CLOSE - + CHAT, MESSAGE, SYNCRECIPES_ADD, SYNCRECIPES_WORKBENCH, DIALOG, QUEST_COMPLETION, EDIT_NPC, PLAY_SOUND, PLAY_MUSIC, UPDATE_NPC, ROLE, GUI, SCRIPTED_PARTICLE, PARTICLE, DELETE_NPC, SCROLL_LIST, SCROLL_DATA, SCROLL_DATA_PART, SCROLL_SELECTED, GUI_REDSTONE, GUI_WAYPOINT, GUI_DATA, GUI_ERROR, GUI_CLOSE, VILLAGER_LIST, CHATBUBBLE, SYNCRECIPES_CARPENTRYBENCH, CLONE, OPEN_BOOK, DIALOG_DUMMY, CONFIG, ISGUIOPEN, OVERLAY_DATA, OVERLAY_CLOSE, SWING_PLAYER_ARM; } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index d3b1fc98f..7ed874a37 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -360,6 +360,10 @@ public class ScriptPlayer extends ScriptLivingBase public void setRotation(float rotationYaw, float rotationPitch){ NoppesUtilPlayer.teleportPlayer(player, player.posX, player.posY, player.posZ, rotationYaw, rotationPitch, player.dimension); } + + public void swingHand(){ + NoppesUtilPlayer.swingPlayerArm(player); + } /** * @param achievement The achievement id. For a complete list see http://minecraft.gamepedia.com/Achievements From 8db16459df8e4cc1962d8104aa412ce8b50758c3 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Mon, 2 May 2022 23:11:45 -0500 Subject: [PATCH 04/75] Made CTRL, Shift, ALT, and Meta keys execute the keyPressed event when pressed down, not just when released. --- .../noppes/npcs/client/ClientTickHandler.java | 36 +++++++------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/main/java/noppes/npcs/client/ClientTickHandler.java b/src/main/java/noppes/npcs/client/ClientTickHandler.java index 43216ce45..299afc566 100644 --- a/src/main/java/noppes/npcs/client/ClientTickHandler.java +++ b/src/main/java/noppes/npcs/client/ClientTickHandler.java @@ -64,33 +64,23 @@ public class ClientTickHandler{ } int key = Keyboard.getEventKey(); - long time = Keyboard.getEventNanoseconds(); + boolean isCtrlPressed = Keyboard.isKeyDown(157) || Keyboard.isKeyDown(29); + boolean isShiftPressed = Keyboard.isKeyDown(54) || Keyboard.isKeyDown(42); + boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56); + boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219); + boolean keyDown = Keyboard.isKeyDown(key); - if(Keyboard.getEventKeyState()) { - if(!this.isIgnoredKey(key)) { - this.buttonTime = time; + StringBuilder keysDownString = new StringBuilder(); + for(int i = 0; i < Keyboard.getKeyCount(); i++){//Creates a comma separated string of the integer IDs of held keys + if(Keyboard.isKeyDown(i)){ + keysDownString.append(Integer.valueOf(i)).append(","); } } - - if(time-this.buttonTime == 0 || !Keyboard.getEventKeyState()) { - boolean isCtrlPressed = Keyboard.isKeyDown(157) || Keyboard.isKeyDown(29); - boolean isShiftPressed = Keyboard.isKeyDown(54) || Keyboard.isKeyDown(42); - boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56); - boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219); - boolean keyDown = Keyboard.isKeyDown(key); - - StringBuilder keysDownString = new StringBuilder(); - for(int i = 0; i < Keyboard.getKeyCount(); i++){//Creates a comma separated string of the integer IDs of held keys - if(Keyboard.isKeyDown(i)){ - keysDownString.append(Integer.valueOf(i)).append(","); - } - } - if(keysDownString.length() > 0){//Removes last comma for later parsing - keysDownString.deleteCharAt(keysDownString.length()-1); - } - - NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, new Object[]{Integer.valueOf(key), Boolean.valueOf(isCtrlPressed), Boolean.valueOf(isShiftPressed), Boolean.valueOf(isAltPressed), Boolean.valueOf(isMetaPressed), Boolean.valueOf(keyDown), keysDownString.toString()}); + if(keysDownString.length() > 0){//Removes last comma for later parsing + keysDownString.deleteCharAt(keysDownString.length()-1); } + + NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, new Object[]{Integer.valueOf(key), Boolean.valueOf(isCtrlPressed), Boolean.valueOf(isShiftPressed), Boolean.valueOf(isAltPressed), Boolean.valueOf(isMetaPressed), Boolean.valueOf(keyDown), keysDownString.toString()}); } private boolean isIgnoredKey(int key) { From d41b3b7a7e5f821b4662ca219cfb058b1bba37a7 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 3 May 2022 11:26:04 -0500 Subject: [PATCH 05/75] ScriptEntity: -Added setInvisible, setSneaking, setSprinting, and getUniqueID() functions. ScriptLivingBase: -Added getLookVec() function ScriptPlayer: -Added stopUsingItem(), clearItemInUse(), playSound(name,volume,pitch), mountEntity(entity), dropOneItem(shouldDropStack), canHarvestBlock(block), interactWith(entity) functions --- .../npcs/scripted/entity/ScriptEntity.java | 16 +++++++++ .../scripted/entity/ScriptLivingBase.java | 4 +++ .../npcs/scripted/entity/ScriptPlayer.java | 34 ++++++++++++++++--- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index ca7d500b2..67d2fe5ad 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -627,6 +627,22 @@ public class ScriptEntity implements IEntity { entity.hurtResistantTime = ticks; }; + public void setInvisible(boolean invisible){ + entity.setInvisible(invisible); + } + + public void setSneaking(boolean sneaking){ + entity.setSneaking(sneaking); + } + + public void setSprinting(boolean sprinting){ + entity.setSprinting(sprinting); + } + + public String getUniqueID(){ + return entity.getUniqueID().toString(); + } + public boolean hasCollided() { return entity.isCollided; } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java index eb1cbed0e..0220ddfc6 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java @@ -117,6 +117,10 @@ public class ScriptLivingBase extends ScriptEntity/effect command diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index 7ed874a37..67f77db16 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -1,5 +1,6 @@ package noppes.npcs.scripted.entity; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; @@ -17,10 +18,7 @@ import noppes.npcs.constants.EnumQuestType; import noppes.npcs.containers.ContainerCustomGui; import noppes.npcs.controllers.*; import noppes.npcs.entity.EntityDialogNpc; -import noppes.npcs.scripted.CustomNPCsException; -import noppes.npcs.scripted.NpcAPI; -import noppes.npcs.scripted.ScriptItemStack; -import noppes.npcs.scripted.ScriptPixelmonPlayerData; +import noppes.npcs.scripted.*; import noppes.npcs.scripted.constants.EntityType; import noppes.npcs.scripted.event.FactionEvent; import noppes.npcs.scripted.gui.ScriptGui; @@ -364,6 +362,34 @@ public class ScriptPlayer extends ScriptLivingBase public void swingHand(){ NoppesUtilPlayer.swingPlayerArm(player); } + + public void stopUsingItem(){ + player.stopUsingItem(); + } + + public void clearItemInUse(){ + player.clearItemInUse(); + } + + public void playSound(String name, float volume, float pitch){ + player.playSound(name, volume, pitch); + } + + public void mountEntity(Entity ridingEntity){ + player.mountEntity(ridingEntity); + } + + public ScriptEntity dropOneItem(boolean dropStack){ + return new ScriptEntity(player.dropOneItem(dropStack)); + } + + public boolean canHarvestBlock(ScriptBlock block){ + return player.canHarvestBlock(block.getMCBlock()); + } + + public boolean interactWith(ScriptEntity entity){ + return player.interactWith(entity.getMCEntity()); + } /** * @param achievement The achievement id. For a complete list see http://minecraft.gamepedia.com/Achievements From 5c9424bac8f0a55ba93e8914dae7be467f548938 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 3 May 2022 13:20:41 -0500 Subject: [PATCH 06/75] Added the repeatKey field to KeyEvent, distinguishing whether the event was triggered by the key being held down or the first press. --- src/main/java/noppes/npcs/EventHooks.java | 4 ++-- src/main/java/noppes/npcs/PacketHandlerPlayer.java | 3 ++- .../java/noppes/npcs/client/ClientTickHandler.java | 11 ++++++----- .../java/noppes/npcs/scripted/event/PlayerEvent.java | 4 +++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/noppes/npcs/EventHooks.java b/src/main/java/noppes/npcs/EventHooks.java index abf0a84a8..c0fe11173 100644 --- a/src/main/java/noppes/npcs/EventHooks.java +++ b/src/main/java/noppes/npcs/EventHooks.java @@ -395,9 +395,9 @@ public class EventHooks { WrapperNpcAPI.EVENT_BUS.post(event); } - public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean buttonDown, int[] heldKeys) { + public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean repeatKey, boolean buttonDown, int[] heldKeys) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - KeyPressedEvent event = new KeyPressedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown, heldKeys); + KeyPressedEvent event = new KeyPressedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, repeatKey, buttonDown, heldKeys); handler.callScript(EnumScriptType.KEY_PRESSED, event); WrapperNpcAPI.EVENT_BUS.post(event); } diff --git a/src/main/java/noppes/npcs/PacketHandlerPlayer.java b/src/main/java/noppes/npcs/PacketHandlerPlayer.java index 963a9f94c..5c4787165 100644 --- a/src/main/java/noppes/npcs/PacketHandlerPlayer.java +++ b/src/main/java/noppes/npcs/PacketHandlerPlayer.java @@ -69,6 +69,7 @@ public class PacketHandlerPlayer{ boolean isShiftPressed = buffer.readBoolean(); boolean isAltPressed = buffer.readBoolean(); boolean isMetaPressed = buffer.readBoolean(); + boolean repeatKey = buffer.readBoolean(); boolean buttonDown = buffer.readBoolean(); String ints = Server.readString(buffer); @@ -88,7 +89,7 @@ public class PacketHandlerPlayer{ keysDown = new int[0]; } - EventHooks.onPlayerKeyPressed(player, button, isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, buttonDown, keysDown); + EventHooks.onPlayerKeyPressed(player, button, isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, repeatKey, buttonDown, keysDown); } else if(type == EnumPlayerPacket.MouseClicked) { if(ScriptController.Instance.languages.isEmpty()) { diff --git a/src/main/java/noppes/npcs/client/ClientTickHandler.java b/src/main/java/noppes/npcs/client/ClientTickHandler.java index 299afc566..c559579d1 100644 --- a/src/main/java/noppes/npcs/client/ClientTickHandler.java +++ b/src/main/java/noppes/npcs/client/ClientTickHandler.java @@ -68,19 +68,20 @@ public class ClientTickHandler{ boolean isShiftPressed = Keyboard.isKeyDown(54) || Keyboard.isKeyDown(42); boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56); boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219); + boolean repeatKey = Keyboard.isRepeatEvent(); boolean keyDown = Keyboard.isKeyDown(key); StringBuilder keysDownString = new StringBuilder(); - for(int i = 0; i < Keyboard.getKeyCount(); i++){//Creates a comma separated string of the integer IDs of held keys - if(Keyboard.isKeyDown(i)){ + for (int i = 0; i < Keyboard.getKeyCount(); i++) {//Creates a comma separated string of the integer IDs of held keys + if (Keyboard.isKeyDown(i)) { keysDownString.append(Integer.valueOf(i)).append(","); } } - if(keysDownString.length() > 0){//Removes last comma for later parsing - keysDownString.deleteCharAt(keysDownString.length()-1); + if (keysDownString.length() > 0) {//Removes last comma for later parsing + keysDownString.deleteCharAt(keysDownString.length() - 1); } - NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, new Object[]{Integer.valueOf(key), Boolean.valueOf(isCtrlPressed), Boolean.valueOf(isShiftPressed), Boolean.valueOf(isAltPressed), Boolean.valueOf(isMetaPressed), Boolean.valueOf(keyDown), keysDownString.toString()}); + NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, new Object[]{Integer.valueOf(key), Boolean.valueOf(isCtrlPressed), Boolean.valueOf(isShiftPressed), Boolean.valueOf(isAltPressed), Boolean.valueOf(isMetaPressed), Boolean.valueOf(repeatKey), Boolean.valueOf(keyDown), keysDownString.toString()}); } private boolean isIgnoredKey(int key) { diff --git a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java index 306bd81f1..36a145b2f 100644 --- a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java @@ -41,16 +41,18 @@ public class PlayerEvent extends CustomNPCsEvent { public final boolean isAltPressed; public final boolean isShiftPressed; public final boolean isMetaPressed; + public final boolean repeatKey; public final boolean keyDown; public final int[] keysDown; - public KeyPressedEvent(IPlayer player, int key, boolean isCtrlPressed, boolean isAltPressed, boolean isShiftPressed, boolean isMetaPressed, boolean keyDown, int[] heldKeys) { + public KeyPressedEvent(IPlayer player, int key, boolean isCtrlPressed, boolean isAltPressed, boolean isShiftPressed, boolean isMetaPressed, boolean repeatKey, boolean keyDown, int[] heldKeys) { super(player); this.key = key; this.isCtrlPressed = isCtrlPressed; this.isAltPressed = isAltPressed; this.isShiftPressed = isShiftPressed; this.isMetaPressed = isMetaPressed; + this.repeatKey = repeatKey; this.keyDown = keyDown; this.keysDown = heldKeys; } From 09f76d84c4f078ba4bda0121d6727c503ec64b95 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 3 May 2022 13:34:56 -0500 Subject: [PATCH 07/75] GuiContainerNPCInterface, GuiNPCInterface, GuiNpcMenu all disable repeat key events when closed like all other GUIs now. The keyEvent scripted event no longer detects repeat held key presses. --- src/main/java/noppes/npcs/EventHooks.java | 4 +-- .../java/noppes/npcs/PacketHandlerPlayer.java | 3 +- .../noppes/npcs/client/ClientTickHandler.java | 33 ++++++++++--------- .../gui/util/GuiContainerNPCInterface.java | 1 + .../npcs/client/gui/util/GuiNPCInterface.java | 1 + .../npcs/client/gui/util/GuiNpcMenu.java | 2 ++ .../npcs/scripted/event/PlayerEvent.java | 4 +-- 7 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/main/java/noppes/npcs/EventHooks.java b/src/main/java/noppes/npcs/EventHooks.java index c0fe11173..abf0a84a8 100644 --- a/src/main/java/noppes/npcs/EventHooks.java +++ b/src/main/java/noppes/npcs/EventHooks.java @@ -395,9 +395,9 @@ public class EventHooks { WrapperNpcAPI.EVENT_BUS.post(event); } - public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean repeatKey, boolean buttonDown, int[] heldKeys) { + public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean buttonDown, int[] heldKeys) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - KeyPressedEvent event = new KeyPressedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, repeatKey, buttonDown, heldKeys); + KeyPressedEvent event = new KeyPressedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown, heldKeys); handler.callScript(EnumScriptType.KEY_PRESSED, event); WrapperNpcAPI.EVENT_BUS.post(event); } diff --git a/src/main/java/noppes/npcs/PacketHandlerPlayer.java b/src/main/java/noppes/npcs/PacketHandlerPlayer.java index 5c4787165..963a9f94c 100644 --- a/src/main/java/noppes/npcs/PacketHandlerPlayer.java +++ b/src/main/java/noppes/npcs/PacketHandlerPlayer.java @@ -69,7 +69,6 @@ public class PacketHandlerPlayer{ boolean isShiftPressed = buffer.readBoolean(); boolean isAltPressed = buffer.readBoolean(); boolean isMetaPressed = buffer.readBoolean(); - boolean repeatKey = buffer.readBoolean(); boolean buttonDown = buffer.readBoolean(); String ints = Server.readString(buffer); @@ -89,7 +88,7 @@ public class PacketHandlerPlayer{ keysDown = new int[0]; } - EventHooks.onPlayerKeyPressed(player, button, isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, repeatKey, buttonDown, keysDown); + EventHooks.onPlayerKeyPressed(player, button, isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, buttonDown, keysDown); } else if(type == EnumPlayerPacket.MouseClicked) { if(ScriptController.Instance.languages.isEmpty()) { diff --git a/src/main/java/noppes/npcs/client/ClientTickHandler.java b/src/main/java/noppes/npcs/client/ClientTickHandler.java index c559579d1..16c08ad20 100644 --- a/src/main/java/noppes/npcs/client/ClientTickHandler.java +++ b/src/main/java/noppes/npcs/client/ClientTickHandler.java @@ -63,25 +63,26 @@ public class ClientTickHandler{ mc.setIngameFocus(); } - int key = Keyboard.getEventKey(); - boolean isCtrlPressed = Keyboard.isKeyDown(157) || Keyboard.isKeyDown(29); - boolean isShiftPressed = Keyboard.isKeyDown(54) || Keyboard.isKeyDown(42); - boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56); - boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219); - boolean repeatKey = Keyboard.isRepeatEvent(); - boolean keyDown = Keyboard.isKeyDown(key); + if(!Keyboard.isRepeatEvent()) { + int key = Keyboard.getEventKey(); + boolean isCtrlPressed = Keyboard.isKeyDown(157) || Keyboard.isKeyDown(29); + boolean isShiftPressed = Keyboard.isKeyDown(54) || Keyboard.isKeyDown(42); + boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56); + boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219); + boolean keyDown = Keyboard.isKeyDown(key); - StringBuilder keysDownString = new StringBuilder(); - for (int i = 0; i < Keyboard.getKeyCount(); i++) {//Creates a comma separated string of the integer IDs of held keys - if (Keyboard.isKeyDown(i)) { - keysDownString.append(Integer.valueOf(i)).append(","); + StringBuilder keysDownString = new StringBuilder(); + for (int i = 0; i < Keyboard.getKeyCount(); i++) {//Creates a comma separated string of the integer IDs of held keys + if (Keyboard.isKeyDown(i)) { + keysDownString.append(Integer.valueOf(i)).append(","); + } + } + if (keysDownString.length() > 0) {//Removes last comma for later parsing + keysDownString.deleteCharAt(keysDownString.length() - 1); } - } - if (keysDownString.length() > 0) {//Removes last comma for later parsing - keysDownString.deleteCharAt(keysDownString.length() - 1); - } - NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, new Object[]{Integer.valueOf(key), Boolean.valueOf(isCtrlPressed), Boolean.valueOf(isShiftPressed), Boolean.valueOf(isAltPressed), Boolean.valueOf(isMetaPressed), Boolean.valueOf(repeatKey), Boolean.valueOf(keyDown), keysDownString.toString()}); + NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, new Object[]{Integer.valueOf(key), Boolean.valueOf(isCtrlPressed), Boolean.valueOf(isShiftPressed), Boolean.valueOf(isAltPressed), Boolean.valueOf(isMetaPressed), Boolean.valueOf(keyDown), keysDownString.toString()}); + } } private boolean isIgnoredKey(int key) { diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface.java b/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface.java index 236556aa3..c1430fd42 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiContainerNPCInterface.java @@ -125,6 +125,7 @@ public abstract class GuiContainerNPCInterface extends GuiContainer public void buttonEvent(GuiButton guibutton){}; public void close(){ + Keyboard.enableRepeatEvents(false); GuiNpcTextField.unfocus(); save(); player.closeScreen(); diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java b/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java index 1e896158f..e8e9b87e3 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java @@ -155,6 +155,7 @@ public abstract class GuiNPCInterface extends GuiScreen GuiNpcTextField.unfocus(); } public void close(){ + Keyboard.enableRepeatEvents(false); displayGuiScreen(null); mc.setIngameFocus(); save(); diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNpcMenu.java b/src/main/java/noppes/npcs/client/gui/util/GuiNpcMenu.java index 3080b54af..fef629e78 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNpcMenu.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNpcMenu.java @@ -99,6 +99,8 @@ public class GuiNpcMenu implements GuiYesNoCallback{ } private void close() { + Keyboard.enableRepeatEvents(false); + if(parent instanceof GuiContainerNPCInterface2) ((GuiContainerNPCInterface2)parent).close(); diff --git a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java index 36a145b2f..306bd81f1 100644 --- a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java @@ -41,18 +41,16 @@ public class PlayerEvent extends CustomNPCsEvent { public final boolean isAltPressed; public final boolean isShiftPressed; public final boolean isMetaPressed; - public final boolean repeatKey; public final boolean keyDown; public final int[] keysDown; - public KeyPressedEvent(IPlayer player, int key, boolean isCtrlPressed, boolean isAltPressed, boolean isShiftPressed, boolean isMetaPressed, boolean repeatKey, boolean keyDown, int[] heldKeys) { + public KeyPressedEvent(IPlayer player, int key, boolean isCtrlPressed, boolean isAltPressed, boolean isShiftPressed, boolean isMetaPressed, boolean keyDown, int[] heldKeys) { super(player); this.key = key; this.isCtrlPressed = isCtrlPressed; this.isAltPressed = isAltPressed; this.isShiftPressed = isShiftPressed; this.isMetaPressed = isMetaPressed; - this.repeatKey = repeatKey; this.keyDown = keyDown; this.keysDown = heldKeys; } From 80e3c075c77e7d3cfa6fca91d06b96091f1d6ed6 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 3 May 2022 14:05:49 -0500 Subject: [PATCH 08/75] Added detectAndSendChanges, putStackInSlot(slot,itemStack), isPlayerNotUsingContainer(player) functions to ScriptContainer --- .../java/noppes/npcs/scripted/ScriptContainer.java | 14 ++++++++++++++ .../npcs/scripted/interfaces/IContainer.java | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/src/main/java/noppes/npcs/scripted/ScriptContainer.java b/src/main/java/noppes/npcs/scripted/ScriptContainer.java index 4e81ce886..450b9a38b 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptContainer.java +++ b/src/main/java/noppes/npcs/scripted/ScriptContainer.java @@ -6,11 +6,13 @@ package noppes.npcs.scripted; import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import noppes.npcs.NoppesUtilPlayer; import noppes.npcs.containers.ContainerCustomGui; +import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.interfaces.IContainer; import noppes.npcs.scripted.interfaces.IItemStack; @@ -87,4 +89,16 @@ public class ScriptContainer implements IContainer { public boolean isCustomGUI() { return this.container instanceof ContainerCustomGui; } + + public void detectAndSendChanges() { + container.detectAndSendChanges(); + } + + public void putStackInSlot(int slot, ScriptItemStack itemStack){ + container.putStackInSlot(slot,itemStack.getMCItemStack()); + } + + public boolean isPlayerNotUsingContainer(ScriptPlayer player){ + return container.isPlayerNotUsingContainer((EntityPlayerMP) player.getMCEntity()); + } } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java b/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java index 6f0b338a6..cca6af790 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java @@ -5,8 +5,11 @@ package noppes.npcs.scripted.interfaces; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; +import noppes.npcs.scripted.ScriptItemStack; +import noppes.npcs.scripted.entity.ScriptPlayer; public interface IContainer { int getSize(); @@ -24,4 +27,10 @@ public interface IContainer { IItemStack[] getItems(); boolean isCustomGUI(); + + void detectAndSendChanges(); + + void putStackInSlot(int slot, ScriptItemStack itemStack); + + boolean isPlayerNotUsingContainer(ScriptPlayer player); } From bfd872a2391e4ba04a564f2ffc8b5f1ec3e96368 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 3 May 2022 23:09:21 -0500 Subject: [PATCH 09/75] ScriptEntity: -Added getEntityId() function -Moved getUniqueId() function ScriptWorld: -Added getPlayerByUUID(uuidstring) function -Added several functions from World and WorldServer: isBlockFreezable,isBlockFreezableNaturally,canBlockFreeze,canBlockFreezeBody,canSnowAt,canSnowAtBody,getTopBlock,getHeightValue,getChunkHeightMapMinimum,getBlockMetadata,setBlockMetadataWithNotify,canBlockSeeTheSky,getFullBlockLightValue,getBlockLightValue,playSoundAtEntity,playSoundToNearExcept,getEntityByID,spawnEntityInWorld,getClosestPlayerToEntity,getClosestPlayer,getClosestVulnerablePlayerToEntity,getClosestVulnerablePlayer,countEntities,setTileEntity,removeTileEntity,isBlockFullCube,getSeed,setSpawnLocation,canLightningStrikeAt,isBlockHighHumidity ScriptTileEntity: Added a ScriptTileEntity class for MC Tile Entities, with nearly all its functions. ScriptBlock: -Added getTileEntity() and setTileEntity() functions using the new ScriptTileEntity class as a return value and parameter respectively. API: -Added playSoundAtEntity and playSoundToNearExcept functions. -Added set/getMOTD() functions. --- .../noppes/npcs/scripted/ScriptBlock.java | 10 ++ .../npcs/scripted/ScriptTileEntity.java | 61 ++++++++ .../noppes/npcs/scripted/ScriptWorld.java | 137 +++++++++++++++++- .../npcs/scripted/entity/ScriptEntity.java | 12 +- .../npcs/scripted/interfaces/ITileEntity.java | 33 +++++ .../npcs/scripted/interfaces/IWorld.java | 66 +++++++++ .../npcs/scripted/wrapper/WrapperNpcAPI.java | 18 +++ 7 files changed, 332 insertions(+), 5 deletions(-) create mode 100644 src/main/java/noppes/npcs/scripted/ScriptTileEntity.java create mode 100644 src/main/java/noppes/npcs/scripted/interfaces/ITileEntity.java diff --git a/src/main/java/noppes/npcs/scripted/ScriptBlock.java b/src/main/java/noppes/npcs/scripted/ScriptBlock.java index 9cf52a980..d7ab06245 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptBlock.java +++ b/src/main/java/noppes/npcs/scripted/ScriptBlock.java @@ -34,6 +34,7 @@ public class ScriptBlock implements IBlock { } protected void setTile(TileEntity tile) { + world.setTileEntity(pos.getX(),pos.getY(), pos.getZ(),new ScriptTileEntity(tile)); this.tile = tile; } @@ -112,6 +113,15 @@ public class ScriptBlock implements IBlock { return this.tile != null; } + public ScriptTileEntity getTileEntity() { + return new ScriptTileEntity(this.tile); + } + + public void setTileEntity(ScriptTileEntity tileEntity){ + world.setTileEntity(pos.getX(),pos.getY(), pos.getZ(),tileEntity); + this.tile = tileEntity.getMCTileEntity(); + } + public TileEntity getMCTileEntity() { return this.tile; } diff --git a/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java b/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java new file mode 100644 index 000000000..5eb9e3966 --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java @@ -0,0 +1,61 @@ +package noppes.npcs.scripted; + +import jdk.nashorn.internal.ir.Block; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.WorldServer; +import noppes.npcs.scripted.interfaces.INbt; +import noppes.npcs.scripted.interfaces.ITileEntity; + +public class ScriptTileEntity implements ITileEntity { + protected T tileEntity; + + public ScriptTileEntity(T tileEntity) { this.tileEntity = tileEntity; } + + public int getBlockMetadata(){ + return tileEntity.getBlockMetadata(); + } + + public ScriptWorld getWorld(){ + return (ScriptWorld) NpcAPI.Instance().getIWorld((WorldServer) tileEntity.getWorldObj()); + } + + public TileEntity getMCTileEntity() { + return this.tileEntity; + } + + public void readFromNBT(INbt nbt){ + this.tileEntity.readFromNBT(nbt.getMCNBT()); + } + + public double getDistanceFrom(double x, double y, double z){ + return this.tileEntity.getDistanceFrom(x,y,z); + } + + public ScriptBlock getBlockType(){ + return new ScriptBlock(tileEntity.getWorldObj(), tileEntity.getBlockType(), new BlockPos(tileEntity.xCoord,tileEntity.yCoord,tileEntity.zCoord)); + } + + public boolean isInvalid(){ + return tileEntity.isInvalid(); + } + + public void invalidate(){ + tileEntity.invalidate(); + } + + public void validate() { + tileEntity.validate(); + } + + public void updateContainingBlockInfo(){ + tileEntity.updateContainingBlockInfo(); + } + + public INbt getNBT() { + NBTTagCompound compound = new NBTTagCompound(); + this.tileEntity.writeToNBT(compound); + return NpcAPI.Instance().getINbt(compound); + } +} diff --git a/src/main/java/noppes/npcs/scripted/ScriptWorld.java b/src/main/java/noppes/npcs/scripted/ScriptWorld.java index cbcc43f48..e0dda6112 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptWorld.java +++ b/src/main/java/noppes/npcs/scripted/ScriptWorld.java @@ -3,11 +3,13 @@ package noppes.npcs.scripted; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.UUID; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -29,6 +31,7 @@ import noppes.npcs.scripted.entity.ScriptEntity; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.interfaces.IBlock; import noppes.npcs.scripted.interfaces.IWorld; +import sun.font.Script; public class ScriptWorld implements IWorld { private static Map tempData = new HashMap(); @@ -54,6 +57,10 @@ public class ScriptWorld implements IWorld { public long getTotalTime(){ return world.getTotalWorldTime(); } + + public boolean areAllPlayersAsleep(){ + return world.areAllPlayersAsleep(); + } /** * @param x World position x @@ -68,6 +75,130 @@ public class ScriptWorld implements IWorld { return new ScriptBlock(world, block, new BlockPos(x,y,z)); } + public boolean isBlockFreezable(int x, int y, int z){ + return world.isBlockFreezable(x,y,z); + } + + public boolean isBlockFreezableNaturally(int x, int y, int z){ + return world.isBlockFreezableNaturally(x,y,z); + } + + public boolean canBlockFreeze(int x, int y, int z, boolean adjacentToWater){ + return world.canBlockFreeze(x,y,z,adjacentToWater); + } + + public boolean canBlockFreezeBody(int x, int y, int z, boolean adjacentToWater){ + return world.canBlockFreezeBody(x,y,z,adjacentToWater); + } + + public boolean canSnowAt(int x, int y, int z, boolean checkLight){ + return world.func_147478_e(x,y,z,checkLight); + } + + public boolean canSnowAtBody(int x, int y, int z, boolean checkLight){ + return world.canSnowAtBody(x,y,z,checkLight); + } + + public IBlock getTopBlock(int x, int z){ + int y; + for (y = 63; !world.isAirBlock(x, y + 1, z); ++y) {;} + Block block = world.getBlock(x, y, z); + + return new ScriptBlock(world, block, new BlockPos(x,y,z)); + } + + public int getHeightValue(int x, int z){ + return world.getHeightValue(x,z); + } + + public int getChunkHeightMapMinimum(int x, int z){ + return world.getChunkHeightMapMinimum(x,z); + } + + public int getBlockMetadata(int x, int y, int z){ + return world.getBlockMetadata(x,y,z); + } + + public boolean setBlockMetadataWithNotify(int x, int y, int z, int metadata, int flag){ + return world.setBlockMetadataWithNotify(x,y,z,metadata,flag); + } + + public boolean canBlockSeeTheSky(int x, int y, int z){ + return world.canBlockSeeTheSky(x,y,z); + } + + public int getFullBlockLightValue(int x, int y, int z){ + return world.getFullBlockLightValue(x,y,z); + } + + public int getBlockLightValue(int x, int y, int z){ + return world.getBlockLightValue(x,y,z); + } + + public void playSoundAtEntity(ScriptEntity entity, String sound, float volume, float pitch){ + world.playSoundAtEntity(entity.getMCEntity(), sound, volume, pitch); + } + + public void playSoundToNearExcept(ScriptPlayer player, String sound, float volume, float pitch){ + world.playSoundToNearExcept((EntityPlayerMP) player.getMCEntity(), sound, volume, pitch); + } + + public ScriptEntity getEntityByID(int id){ + return (ScriptEntity) NpcAPI.Instance().getIEntity(world.getEntityByID(id)); + } + + public boolean spawnEntityInWorld(ScriptEntity entity){ + return world.spawnEntityInWorld(entity.getMCEntity()); + } + + public ScriptPlayer getClosestPlayerToEntity(ScriptEntity entity, double range){ + return (ScriptPlayer) NpcAPI.Instance().getIEntity(world.getClosestPlayerToEntity(entity.getMCEntity(), range)); + } + + public ScriptPlayer getClosestPlayer(double x, double y, double z, double range){ + return (ScriptPlayer) NpcAPI.Instance().getIEntity(world.getClosestPlayer(x,y,z, range)); + } + + public ScriptPlayer getClosestVulnerablePlayerToEntity(ScriptEntity entity, double range){ + return (ScriptPlayer) NpcAPI.Instance().getIEntity(world.getClosestVulnerablePlayerToEntity(entity.getMCEntity(), range)); + } + + public ScriptPlayer getClosestVulnerablePlayer(double x, double y, double z, double range){ + return (ScriptPlayer) NpcAPI.Instance().getIEntity(world.getClosestVulnerablePlayer(x,y,z, range)); + } + + public int countEntities(ScriptEntity entity){ + return world.countEntities(entity.getMCEntity().getClass()); + } + + public void setTileEntity(int x, int y, int z, ScriptTileEntity tileEntity){ + world.setTileEntity(x,y,z,tileEntity.getMCTileEntity()); + } + + public void removeTileEntity(int x, int y, int z){ + world.removeTileEntity(x,y,z); + } + + public boolean isBlockFullCube(int x, int y, int z){ + return world.func_147469_q(x,y,z); + } + + public long getSeed(){ + return world.getSeed(); + } + + public void setSpawnLocation(int x, int y, int z){ + world.setSpawnLocation(x,y,z); + } + + public boolean canLightningStrikeAt(int x, int y, int z){ + return world.canLightningStrikeAt(x,y,z); + } + + public boolean isBlockHighHumidity(int x, int y, int z){ + return world.isBlockHighHumidity(x,y,z); + } + /** * @param x World position x * @param y World position y @@ -129,6 +260,10 @@ public class ScriptWorld implements IWorld { return null; return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(player); } + + public ScriptPlayer getPlayerByUUID(String uuid){ + return (ScriptPlayer) NpcAPI.Instance().getIEntity(world.func_152378_a(UUID.fromString(uuid))); + } /** * @param time The world time to be set @@ -136,7 +271,7 @@ public class ScriptWorld implements IWorld { public void setTime(long time){ world.setWorldTime(time); } - + /** * @return Whether or not its daytime */ diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index 67d2fe5ad..4989d6e1c 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -167,6 +167,14 @@ public class ScriptEntity implements IEntity { } public void spawnParticle(ScriptEntityParticle entityParticle) { entityParticle.spawnOnEntity(this); } + public int getEntityId(){ + return entity.getEntityId(); + } + + public String getUniqueID(){ + return entity.getUniqueID().toString(); + } + public double getYOffset() { return entity.getYOffset(); } /** @@ -639,10 +647,6 @@ public class ScriptEntity implements IEntity { entity.setSprinting(sprinting); } - public String getUniqueID(){ - return entity.getUniqueID().toString(); - } - public boolean hasCollided() { return entity.isCollided; } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ITileEntity.java b/src/main/java/noppes/npcs/scripted/interfaces/ITileEntity.java new file mode 100644 index 000000000..ca2dd8e9e --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/interfaces/ITileEntity.java @@ -0,0 +1,33 @@ +package noppes.npcs.scripted.interfaces; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.WorldServer; +import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.ScriptBlock; +import noppes.npcs.scripted.ScriptWorld; + +public interface ITileEntity { + int getBlockMetadata(); + + ScriptWorld getWorld(); + + TileEntity getMCTileEntity(); + + void readFromNBT(INbt nbt); + + double getDistanceFrom(double x, double y, double z); + + ScriptBlock getBlockType(); + + boolean isInvalid(); + + void invalidate(); + + void validate(); + + void updateContainingBlockInfo(); + + INbt getNBT(); +} diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java index 9c7b14534..c378e6894 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java @@ -1,5 +1,7 @@ package noppes.npcs.scripted.interfaces; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.WorldServer; @@ -18,6 +20,8 @@ public interface IWorld { */ public long getTotalTime(); + boolean areAllPlayersAsleep(); + /** * @param x World position x * @param y World position y @@ -26,6 +30,66 @@ public interface IWorld { */ public IBlock getBlock(int x, int y, int z); + IBlock getTopBlock(int x, int z); + + public boolean isBlockFreezable(int x, int y, int z); + + public boolean isBlockFreezableNaturally(int x, int y, int z); + + public boolean canBlockFreeze(int x, int y, int z, boolean adjacentToWater); + + public boolean canBlockFreezeBody(int x, int y, int z, boolean adjacentToWater); + + public boolean canSnowAt(int x, int y, int z, boolean checkLight); + + public boolean canSnowAtBody(int x, int y, int z, boolean checkLight); + + public int getHeightValue(int x, int z); + + public int getChunkHeightMapMinimum(int x, int z); + + public int getBlockMetadata(int x, int y, int z); + + public boolean setBlockMetadataWithNotify(int x, int y, int z, int metadata, int flag); + + public boolean canBlockSeeTheSky(int x, int y, int z); + + public int getFullBlockLightValue(int x, int y, int z); + + public int getBlockLightValue(int x, int y, int z); + + public void playSoundAtEntity(ScriptEntity entity, String sound, float volume, float pitch); + + public void playSoundToNearExcept(ScriptPlayer player, String sound, float volume, float pitch); + + public ScriptEntity getEntityByID(int id); + + public boolean spawnEntityInWorld(ScriptEntity entity); + + public ScriptPlayer getClosestPlayerToEntity(ScriptEntity entity, double range); + + public ScriptPlayer getClosestPlayer(double x, double y, double z, double range); + + public ScriptPlayer getClosestVulnerablePlayerToEntity(ScriptEntity entity, double range); + + public ScriptPlayer getClosestVulnerablePlayer(double x, double y, double z, double range); + + public int countEntities(ScriptEntity entity); + + public void setTileEntity(int x, int y, int z, ScriptTileEntity tileEntity); + + public void removeTileEntity(int x, int y, int z); + + public boolean isBlockFullCube(int x, int y, int z); + + public long getSeed(); + + public void setSpawnLocation(int x, int y, int z); + + public boolean canLightningStrikeAt(int x, int y, int z); + + boolean isBlockHighHumidity(int x, int y, int z); + /** * @param x World position x * @param y World position y @@ -56,6 +120,8 @@ public interface IWorld { */ public ScriptPlayer getPlayer(String name); + ScriptPlayer getPlayerByUUID(String uuid); + /** * @param time The world time to be set */ diff --git a/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java b/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java index 631f486c6..5fb686421 100644 --- a/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java @@ -265,6 +265,24 @@ public class WrapperNpcAPI extends NpcAPI { return new ScriptItemStack(new ItemStack(item, size, damage)); } + public void playSoundAtEntity(ScriptEntity entity, String sound, float volume, float pitch){ + entity.getWorld().getMCWorld().playSoundAtEntity(entity.getMCEntity(), sound, volume, pitch); + } + + public void playSoundToNearExcept(ScriptPlayer player, String sound, float volume, float pitch){ + player.getWorld().getMCWorld().playSoundToNearExcept((EntityPlayerMP) player.getMCEntity(), sound, volume, pitch); + } + + public String getMOTD() + { + return MinecraftServer.getServer().getMOTD(); + } + + public void setMOTD(String motd) + { + MinecraftServer.getServer().setMOTD(motd); + } + public ScriptEntityParticle createEntityParticle(String directory){ return new ScriptEntityParticle(directory); } From 85a1892c71bf5d5ccd3a3c6e87958a1f004d8728 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 4 May 2022 03:06:40 -0500 Subject: [PATCH 10/75] Changes to NPC flight: -Improved flight pathing greatly, MUCH MUCH smoother now. -The "flying speed" of an NPC now correctly speeds up how fast the NPC climbs vertically while flying -NPCs now properly return to start while flying --- .../java/noppes/npcs/ai/EntityAIReturn.java | 11 +- .../npcs/ai/pathfinder/FlyingMoveHelper.java | 12 +- .../ai/pathfinder/PathNavigateFlying.java | 138 +----------------- .../npcs/entity/EntityNPCInterface.java | 9 +- 4 files changed, 20 insertions(+), 150 deletions(-) diff --git a/src/main/java/noppes/npcs/ai/EntityAIReturn.java b/src/main/java/noppes/npcs/ai/EntityAIReturn.java index 6bf891e5a..157dd6b7b 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIReturn.java +++ b/src/main/java/noppes/npcs/ai/EntityAIReturn.java @@ -29,8 +29,12 @@ public class EntityAIReturn extends EntityAIBase /** * Returns whether the EntityAIBase should begin execution. */ - public boolean shouldExecute(){ - if(npc.hasOwner() || !npc.ai.returnToStart || npc.isKilled() || !npc.getNavigator().noPath() || npc.isInteracting()){ + public boolean shouldExecute() { + if (npc.getNavigator().noPath() || (!npc.isAttacking() && wasAttacked)){ + return true; + } + + if(npc.hasOwner() || !npc.ai.returnToStart || npc.isKilled() || npc.isInteracting()){ return false; } @@ -52,9 +56,6 @@ public class EntityAIReturn extends EntityAIBase } return false; } - if(!npc.isAttacking() && wasAttacked){ - return true; - } if(npc.ai.movingType == EnumMovingType.MovingPath && npc.ai.getDistanceSqToPathPoint() < CustomNpcs.NpcNavRange * CustomNpcs.NpcNavRange) return false; diff --git a/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java b/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java index f47667a08..71c9e94e6 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java @@ -29,10 +29,10 @@ public class FlyingMoveHelper extends EntityMoveHelper{ if (this.update) { this.update = false; - double speed = this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue() * this.entity.ai.flySpeed; + double speed = this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue(); double d0 = this.posX - this.entity.posX; - double d1 = this.posY - MathHelper.floor_double(this.entity.boundingBox.minY + 0.05D); + double d1 = this.posY - this.entity.posY;//MathHelper.floor_double(this.entity.boundingBox.minY + 0.05D); double d2 = this.posZ - this.entity.posZ; double d4 = d0 * d0 + d1 * d1 + d2 * d2; double d5 = MathHelper.sqrt_double(d4); @@ -48,17 +48,17 @@ public class FlyingMoveHelper extends EntityMoveHelper{ } if (this.entity.hurtTime == 0 && d4 > 0.5D) { - this.entity.motionX += (d0 / d5 * speed - this.entity.motionX) * speed; - this.entity.motionZ += (d2 / d5 * speed - this.entity.motionZ) * speed; + this.entity.motionX += (speed * (d0 / d5) - this.entity.motionX) * speed; + this.entity.motionZ += (speed * (d2 / d5) - this.entity.motionZ) * speed; if (heightOffGround < this.entity.ai.flyHeightLimit || !this.entity.ai.hasFlyLimit) { - this.entity.motionY += (d1 / d5 * speed - this.entity.motionY) * speed; + this.entity.motionY += ((speed + this.entity.ai.flySpeed/10.0D + 0.05) * (d1 / d5) - this.entity.motionY) * (speed + this.entity.ai.flySpeed/10.0D + 0.05); } this.entity.velocityChanged = true; } - this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),18.0F); + this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),15.0F); } } diff --git a/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java b/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java index 581c46139..ce16f2b4b 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java @@ -118,7 +118,7 @@ public class PathNavigateFlying extends PathNavigate { */ public FlyPathEntity getPathToXYZ(double p_75488_1_, double p_75488_3_, double p_75488_5_) { - return !this.canNavigate() ? null : this.getEntityPathToXYZ(this.theEntity, MathHelper.floor_double(p_75488_1_), (int)p_75488_3_, MathHelper.floor_double(p_75488_5_), this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim); + return this.getEntityPathToXYZ(this.theEntity, MathHelper.floor_double(p_75488_1_), (int)p_75488_3_, MathHelper.floor_double(p_75488_5_), this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim); } /** @@ -135,7 +135,7 @@ public class PathNavigateFlying extends PathNavigate { */ public FlyPathEntity getPathToEntityLiving(Entity p_75494_1_) { - return !this.canNavigate() ? null : this.getPathEntityToEntity(this.theEntity, p_75494_1_, this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim); + return this.getPathEntityToEntity(this.theEntity, p_75494_1_, this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim); } /** @@ -202,10 +202,7 @@ public class PathNavigateFlying extends PathNavigate { if (!this.noPath()) { - if (this.canNavigate()) - { - this.pathFollow(); - } + this.pathFollow(); if (!this.noPath()) { @@ -224,15 +221,6 @@ public class PathNavigateFlying extends PathNavigate { Vec3 vec3 = this.getEntityPosition(); int i = this.currentPath.getCurrentPathLength(); - for (int j = this.currentPath.getCurrentPathIndex(); j < this.currentPath.getCurrentPathLength(); ++j) - { - if (this.currentPath.getPathPointFromIndex(j).yCoord != (int)vec3.yCoord) - { - i = j; - break; - } - } - float f = this.theEntity.width * this.theEntity.width; int k; @@ -300,23 +288,6 @@ public class PathNavigateFlying extends PathNavigate { return this.theEntity.boundingBox.minY + 0.05D; } - /** - * If on ground or swimming and can swim - */ - private boolean canNavigate() - { - return true; - } - - /** - * Returns true when an entity could stand at a position, including solid blocks under the entire entity. Args: - * xOffset, yOffset, zOffset, entityXSize, entityYSize, entityZSize, originPosition, vecX, vecZ - */ - private boolean isSafeToStandAt(int p_75483_1_, int p_75483_2_, int p_75483_3_, int p_75483_4_, int p_75483_5_, int p_75483_6_, Vec3 p_75483_7_, double p_75483_8_, double p_75483_10_) - { - return true; - } - /** * Trims path data from the end to the first sun covered block */ @@ -343,112 +314,11 @@ public class PathNavigateFlying extends PathNavigate { */ private boolean isDirectPathBetweenPoints(Vec3 p_75493_1_, Vec3 p_75493_2_, int p_75493_3_, int p_75493_4_, int p_75493_5_) { - int l = MathHelper.floor_double(p_75493_1_.xCoord); - int i1 = MathHelper.floor_double(p_75493_1_.zCoord); double d0 = p_75493_2_.xCoord - p_75493_1_.xCoord; double d1 = p_75493_2_.zCoord - p_75493_1_.zCoord; double d2 = d0 * d0 + d1 * d1; - if (d2 < 1.0E-8D) - { - return false; - } - else - { - double d3 = 1.0D / Math.sqrt(d2); - d0 *= d3; - d1 *= d3; - p_75493_3_ += 2; - p_75493_5_ += 2; - - if (!this.isSafeToStandAt(l, (int)p_75493_1_.yCoord, i1, p_75493_3_, p_75493_4_, p_75493_5_, p_75493_1_, d0, d1)) - { - return false; - } - else - { - p_75493_3_ -= 2; - p_75493_5_ -= 2; - double d4 = 1.0D / Math.abs(d0); - double d5 = 1.0D / Math.abs(d1); - double d6 = (double)(l * 1) - p_75493_1_.xCoord; - double d7 = (double)(i1 * 1) - p_75493_1_.zCoord; - - if (d0 >= 0.0D) - { - ++d6; - } - - if (d1 >= 0.0D) - { - ++d7; - } - - d6 /= d0; - d7 /= d1; - int j1 = d0 < 0.0D ? -1 : 1; - int k1 = d1 < 0.0D ? -1 : 1; - int l1 = MathHelper.floor_double(p_75493_2_.xCoord); - int i2 = MathHelper.floor_double(p_75493_2_.zCoord); - int j2 = l1 - l; - int k2 = i2 - i1; - - do - { - if (j2 * j1 <= 0 && k2 * k1 <= 0) - { - return true; - } - - if (d6 < d7) - { - d6 += d4; - l += j1; - j2 = l1 - l; - } - else - { - d7 += d5; - i1 += k1; - k2 = i2 - i1; - } - } - while (this.isSafeToStandAt(l, (int)p_75493_1_.yCoord, i1, p_75493_3_, p_75493_4_, p_75493_5_, p_75493_1_, d0, d1)); - - return false; - } - } - } - - /** - * Returns true if an entity does not collide with any solid blocks at the position. Args: xOffset, yOffset, - * zOffset, entityXSize, entityYSize, entityZSize, originPosition, vecX, vecZ - */ - private boolean isPositionClear(int p_75496_1_, int p_75496_2_, int p_75496_3_, int p_75496_4_, int p_75496_5_, int p_75496_6_, Vec3 p_75496_7_, double p_75496_8_, double p_75496_10_) - { - for (int k1 = p_75496_1_; k1 < p_75496_1_ + p_75496_4_; ++k1) - { - for (int l1 = p_75496_2_; l1 < p_75496_2_ + p_75496_5_; ++l1) - { - for (int i2 = p_75496_3_; i2 < p_75496_3_ + p_75496_6_; ++i2) - { - double d2 = (double)k1 + 0.5D - p_75496_7_.xCoord; - double d3 = (double)i2 + 0.5D - p_75496_7_.zCoord; - - if (d2 * p_75496_8_ + d3 * p_75496_10_ >= 0.0D) - { - Block block = this.worldObj.getBlock(k1, l1, i2); - - if (!block.getBlocksMovement(this.worldObj, k1, l1, i2)) - { - return false; - } - } - } - } - } - - return true; + return !(d2 < 1.0E-8D); } public FlyPathEntity getPathEntityToEntity(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_) diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index c8b672a82..872cf6b74 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -232,7 +232,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti public int getMaxSafePointTries() { - return 5; + return 10; } @Override @@ -426,13 +426,13 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti protected void updateAITasks() { + this.getNavigator().onUpdateNavigation(); + this.getMoveHelper().onUpdateMoveHelper(); + try { super.updateAITasks(); } catch (ConcurrentModificationException ignored){ } - - this.getNavigator().onUpdateNavigation(); - this.getMoveHelper().onUpdateMoveHelper(); } public void addInteract(EntityLivingBase entity){ @@ -631,7 +631,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti if (canFly()) { this.getNavigator().setCanSwim(true); - this.tasks.addTask(0, new EntityAISwimming(this)); } else { this.tasks.addTask(0, new EntityAIWaterNav(this)); } From a2dd0e502a720cda55a104b6d5e44bf6ba4123d4 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 4 May 2022 03:10:16 -0500 Subject: [PATCH 11/75] Slightly improved return to start checks --- src/main/java/noppes/npcs/ai/EntityAIReturn.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/noppes/npcs/ai/EntityAIReturn.java b/src/main/java/noppes/npcs/ai/EntityAIReturn.java index 157dd6b7b..9c3988ac3 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIReturn.java +++ b/src/main/java/noppes/npcs/ai/EntityAIReturn.java @@ -30,11 +30,15 @@ public class EntityAIReturn extends EntityAIBase * Returns whether the EntityAIBase should begin execution. */ public boolean shouldExecute() { + if (!npc.ai.returnToStart){ + return false; + } + if (npc.getNavigator().noPath() || (!npc.isAttacking() && wasAttacked)){ return true; } - if(npc.hasOwner() || !npc.ai.returnToStart || npc.isKilled() || npc.isInteracting()){ + if(npc.hasOwner() || npc.isKilled() || npc.isInteracting()){ return false; } From 8033b8ba1932d0da7d00e37add67a31da315e189 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 4 May 2022 04:10:14 -0500 Subject: [PATCH 12/75] Tweaked vertical speed calculations for NPC flight --- .../java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java b/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java index 71c9e94e6..f1d42f02a 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java @@ -30,9 +30,10 @@ public class FlyingMoveHelper extends EntityMoveHelper{ this.update = false; double speed = this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue(); + double verticalSpeed = this.speed * this.entity.ai.flySpeed/8.0D; double d0 = this.posX - this.entity.posX; - double d1 = this.posY - this.entity.posY;//MathHelper.floor_double(this.entity.boundingBox.minY + 0.05D); + double d1 = this.posY - this.entity.posY; double d2 = this.posZ - this.entity.posZ; double d4 = d0 * d0 + d1 * d1 + d2 * d2; double d5 = MathHelper.sqrt_double(d4); @@ -52,7 +53,7 @@ public class FlyingMoveHelper extends EntityMoveHelper{ this.entity.motionZ += (speed * (d2 / d5) - this.entity.motionZ) * speed; if (heightOffGround < this.entity.ai.flyHeightLimit || !this.entity.ai.hasFlyLimit) { - this.entity.motionY += ((speed + this.entity.ai.flySpeed/10.0D + 0.05) * (d1 / d5) - this.entity.motionY) * (speed + this.entity.ai.flySpeed/10.0D + 0.05); + this.entity.motionY = verticalSpeed * (d1 / d5); } this.entity.velocityChanged = true; From 1cd3ff31b61d291c3d3d95e46067c02c9550eeb3 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 4 May 2022 04:58:59 -0500 Subject: [PATCH 13/75] Increased the angle limit while pathing for flying NPCs from 15 to 20 degrees --- src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java b/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java index f1d42f02a..a722b04af 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java @@ -59,7 +59,7 @@ public class FlyingMoveHelper extends EntityMoveHelper{ this.entity.velocityChanged = true; } - this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),15.0F); + this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),20.0F); } } From f16e2402a6142d550503969503afade9ab8e1c55 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 4 May 2022 18:08:54 -0500 Subject: [PATCH 14/75] ScriptEntityParticle: -Added scripted particles which can not face the player, having their angles be absolute in the world instead of relative to the camera. -set/getFacePlayer() functions added. --- .../java/noppes/npcs/NoppesUtilServer.java | 2 + .../java/noppes/npcs/client/NoppesUtil.java | 4 +- .../noppes/npcs/client/fx/EntityCustomFX.java | 37 ++++++++---- .../npcs/scripted/ScriptEntityParticle.java | 6 ++ .../npcs/scripted/entity/ScriptEntity.java | 6 ++ .../npcs/scripted/interfaces/IEntity.java | 56 ------------------- 6 files changed, 44 insertions(+), 67 deletions(-) diff --git a/src/main/java/noppes/npcs/NoppesUtilServer.java b/src/main/java/noppes/npcs/NoppesUtilServer.java index eff4322f9..2141f5d83 100644 --- a/src/main/java/noppes/npcs/NoppesUtilServer.java +++ b/src/main/java/noppes/npcs/NoppesUtilServer.java @@ -320,6 +320,7 @@ public class NoppesUtilServer { float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart, float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart, float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart, + boolean facePlayer, int entityID ){ Server.sendToAll(EnumPacketClient.SCRIPTED_PARTICLE, @@ -331,6 +332,7 @@ public class NoppesUtilServer { rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, + facePlayer, entityID ); } diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index d9aee3bf3..035478c4d 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -113,6 +113,8 @@ public class NoppesUtil { float rotationZRate = buffer.readFloat(); int rotationZRateStart = buffer.readInt(); + boolean facePlayer = buffer.readBoolean(); + int entityID = buffer.readInt(); World worldObj = Minecraft.getMinecraft().theWorld; @@ -131,7 +133,7 @@ public class NoppesUtil { rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, - maxAge + maxAge, facePlayer ); for(int i = 0; i < amount; i++){ diff --git a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java index 8f8ce3861..39f8e4b68 100644 --- a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java +++ b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java @@ -44,6 +44,8 @@ public class EntityCustomFX extends EntityFX { public float rotationZRate = 0.0F; public int rotationZRateStart = 0; + public boolean facePlayer = true; + public EntityCustomFX(Entity entity, String directory, int HEXColor, double x, double y, double z, double motionX, double motionY, double motionZ, float gravity, float scale1, float scale2, float scaleRate, int scaleRateStart, @@ -51,7 +53,7 @@ public class EntityCustomFX extends EntityFX { float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart, float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart, float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart, - int age) { + int age, boolean facePlayer) { super(entity.worldObj, x, y, z, motionX, motionY, motionZ); this.scale1 = scale1; @@ -116,6 +118,8 @@ public class EntityCustomFX extends EntityFX { } location = new ResourceLocation(directory); + + this.facePlayer = facePlayer; } @Override @@ -178,16 +182,29 @@ public class EntityCustomFX extends EntityFX { double yaw = (player.rotationYaw/180)*Math.PI; double pitch = (player.rotationPitch/180)*Math.PI; - if(Math.abs(rotationX%360) >= 90 && Math.abs(rotationX%360) < 270) { - rotationX += 180*Math.signum(rotationX); - } - if(Math.abs(rotationY%360) >= 90 && Math.abs(rotationY%360) < 270) { - rotationY += 180*Math.signum(rotationY); - } + if(facePlayer) { + if (Math.abs(rotationX % 360) >= 90 && Math.abs(rotationX % 360) < 270) { + rotationX += 180 * Math.signum(rotationX); + } + if (Math.abs(rotationY % 360) >= 90 && Math.abs(rotationY % 360) < 270) { + rotationY += 180 * Math.signum(rotationY); + } - GL11.glRotated(rotationX, Math.cos(yaw)*Math.cos(pitch),0.0,Math.sin(yaw)*Math.cos(pitch)); - GL11.glRotated(rotationY, -Math.sin(yaw)*Math.sin(pitch), Math.cos(pitch), Math.cos(yaw)*Math.sin(pitch)); - GL11.glRotated(rotationZ, Math.sin(yaw)*Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw)*Math.cos(pitch)); + GL11.glRotated(rotationX, Math.cos(yaw) * Math.cos(pitch), 0.0, Math.sin(yaw) * Math.cos(pitch)); + GL11.glRotated(rotationY, -Math.sin(yaw) * Math.sin(pitch), Math.cos(pitch), Math.cos(yaw) * Math.sin(pitch)); + GL11.glRotated(rotationZ, Math.sin(yaw) * Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw) * Math.cos(pitch)); + } else { + GL11.glRotated(player.rotationYaw % 360, 0.0, 1.0, 0.0); + GL11.glRotated(rotationY, 0.0, 1.0, 0.0); + GL11.glRotated(rotationX, Math.cos(yaw), 0.0, Math.sin(yaw)); + GL11.glRotated(rotationZ, Math.sin(yaw), 0.0, -Math.cos(yaw)); + GL11.glRotated((90 - player.rotationPitch), Math.cos(yaw), 0.0, Math.sin(yaw)); + } + /* + if(Minecraft.getMinecraft().currentScreen == null){ + System.out.println(); + } + */ tessellator.startDrawingQuads(); tessellator.setBrightness(240); diff --git a/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java b/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java index 01d913d13..c81aac693 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java +++ b/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java @@ -33,6 +33,8 @@ public class ScriptEntityParticle { public float rotationZRate = 0.0F; public int rotationZRateStart = 0; + public boolean facePlayer = true; + public ScriptEntityParticle(String directory){ this.directory = directory; } @@ -47,10 +49,14 @@ public class ScriptEntityParticle { rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, + facePlayer, entityID ); } + public boolean getFacePlayer() { return facePlayer; } + public void setFacePlayer(boolean facePlayer) { this.facePlayer = facePlayer; } + public String getDirectory() { return directory; } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index 4989d6e1c..09bb5b4dc 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -82,6 +82,7 @@ public class ScriptEntity implements IEntity { rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, + true, entityID ); } @@ -100,6 +101,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + true, entityID ); } @@ -117,6 +119,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + true, entityID ); } @@ -133,6 +136,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + true, entityID ); } @@ -148,6 +152,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + true, entityID ); } @@ -162,6 +167,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + true, entityID ); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java b/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java index a806676d9..895e6b242 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java @@ -10,62 +10,6 @@ import noppes.npcs.scripted.entity.ScriptEntity; import noppes.npcs.scripted.ScriptItemStack; public interface IEntity { - /** - * @param directory The particle's directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/tail.png" - * @param HEXcolor The particle's color as a HEX integer - * @param amount The amount of particles to spawn - * @param maxAge The particle's maximum age in MC ticks - - * @param x The particle's x position - * @param y The particle's y position - * @param z The particle's z position - - * @param motionX The particle's speed in the x axis - * @param motionY The particle's speed in the y axis - * @param motionZ The particle's speed in the z axis - * @param gravity The particle's gravity - - * @param scale1 The particle's starting scale - * @param scale2 The particle's ending scale - * @param scaleRate Multiplier for the particle's scale growth rate - * @param scaleRateStart The time at which the particle begins growing/shrinking - - * @param alpha1 The particle's starting transparency - * @param alpha2 The particle's ending transparency - * @param scaleRate Multiplier for the particle's transparency growth rate - * @param alphaRateStart The time at which the particle begins appearing/fading - * - * @param rotation1 The particle's starting rotation angle with respect to the player's vision - * @param rotation2 The particle's final rotation angle with respect to the player's vision - * @param rotationRate The rate at which the particle rotates with respect to the player's vision - * @param rotationRateStart The time at which the particle begins rotating - - * @param rotationX1 The particle's starting rotation angle with respect to the X-axis - * @param rotationX2 The particle's final rotation angle with respect to the X-axis - * @param rotationXRate The rate at which the particle rotates with respect to the X-axis - * @param rotationXRateStart The time at which the particle begins rotating over the X-axis - - * @param rotationY1 The particle's starting rotation angle with respect to the Y-axis - * @param rotationY2 The particle's final rotation angle with respect to the Y-axis - * @param rotationYRate The rate at which the particle rotates with respect to the Y-axis - * @param rotationYRateStart The time at which the particle begins rotating over the Y-axis - - * @param rotationZ1 The particle's starting rotation angle with respect to the Z-axis - * @param rotationZ2 The particle's final rotation angle with respect to the Z-axis - * @param rotationZRate The rate at which the particle rotates with respect to the Z-axis - * @param rotationZRateStart The time at which the particle begins rotating over the Z-axis - */ - void spawnParticle(String directory, int HEXcolor, int amount, int maxAge, - double x, double y, double z, - double motionX, double motionY, double motionZ, float gravity, - float scale1, float scale2, float scaleRate, int scaleRateStart, - float alpha1, float alpha2, float alphaRate, int alphaRateStart, - float rotation1, float rotation2, float rotationRate, int rotationRateStart, - float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart, - float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart, - float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart - ); - public double getYOffset(); /** From 034707abd3159145264fc30a644afefd4de67211 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 4 May 2022 21:41:32 -0500 Subject: [PATCH 15/75] ScriptEntityParticle: -Fixed rotations with scripted particles --- .../noppes/npcs/client/fx/EntityCustomFX.java | 142 ++++++++++-------- 1 file changed, 78 insertions(+), 64 deletions(-) diff --git a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java index 39f8e4b68..92b2e4014 100644 --- a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java +++ b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java @@ -126,70 +126,63 @@ public class EntityCustomFX extends EntityFX { public void renderParticle(Tessellator tessellator, float partialTick, float cosYaw, float cosPitch, float sinYaw, float sinSinPitch, float cosSinPitch) { tessellator.draw(); + + if(move){ + startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTick); + startY = (float)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTick); + startZ = (float)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTick); + } + + float scaleChange = this.scaleRate / (float)particleMaxAge; + if((this.scaleRate < 0 && particleScale+scaleChange < this.scale2) || (this.scaleRate > 0 && particleScale+scaleChange > this.scale2)) + particleScale = this.scale2; + else if(particleAge >= this.scaleRateStart) + particleScale += scaleChange; + + float alphaChange = this.alphaRate / (float)particleMaxAge; + if((this.alphaRate < 0 && particleAlpha+alphaChange < this.alpha2) || (this.alphaRate > 0 && particleAlpha+alphaChange > this.alpha2)) + particleAlpha = this.alpha2; + else if(particleAge >= this.alphaRateStart) + particleAlpha += alphaChange; + + float rotationXChange = this.rotationXRate / (float)particleMaxAge; + if((this.rotationXRate < 0 && rotationX+rotationXChange < this.rotationX2) || (this.rotationXRate > 0 && rotationX+rotationXChange > this.rotationX2)) + rotationX = this.rotationX2; + else if(particleAge >= this.rotationXRateStart) + rotationX += rotationXChange; + + float rotationYChange = this.rotationYRate / (float)particleMaxAge; + if((this.rotationYRate < 0 && rotationY+rotationYChange < this.rotationY2) || (this.rotationYRate > 0 && rotationY+rotationYChange > this.rotationY2)) + rotationY = this.rotationY2; + else if(particleAge >= this.rotationYRateStart) + rotationY += rotationYChange; + + float rotationZChange = this.rotationZRate / (float)particleMaxAge; + if((this.rotationZRate < 0 && rotationZ+rotationZChange < this.rotationZ2) || (this.rotationZRate > 0 && rotationZ+rotationZChange > this.rotationZ2)) + rotationZ = this.rotationZ2; + else if(particleAge >= this.rotationZRateStart) + rotationZ += rotationZChange; + + float u1 = 0.0f; + float u2 = 1.0f; + float v1 = 0.0f; + float v2 = 1.0f; + + float renderScale = 0.1F * particleScale; + + float posX = (float)(((prevPosX + (this.posX - prevPosX) * (double)partialTick) - interpPosX) + startX); + float posY = (float)(((prevPosY + (this.posY - prevPosY) * (double)partialTick) - interpPosY) + startY); + float posZ = (float)(((prevPosZ + (this.posZ - prevPosZ) * (double)partialTick) - interpPosZ) + startZ); + + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + double yaw = (player.rotationYaw/180)*Math.PI; + double pitch = (player.rotationPitch/180)*Math.PI; + GL11.glPushMatrix(); ClientProxy.bindTexture(location); - - if(move){ - startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTick); - startY = (float)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTick); - startZ = (float)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTick); - } - - float scaleChange = this.scaleRate / (float)particleMaxAge; - if((this.scaleRate < 0 && particleScale+scaleChange < this.scale2) || (this.scaleRate > 0 && particleScale+scaleChange > this.scale2)) - particleScale = this.scale2; - else if(particleAge >= this.scaleRateStart) - particleScale += scaleChange; - - float alphaChange = this.alphaRate / (float)particleMaxAge; - if((this.alphaRate < 0 && particleAlpha+alphaChange < this.alpha2) || (this.alphaRate > 0 && particleAlpha+alphaChange > this.alpha2)) - particleAlpha = this.alpha2; - else if(particleAge >= this.alphaRateStart) - particleAlpha += alphaChange; - - float rotationXChange = this.rotationXRate / (float)particleMaxAge; - if((this.rotationXRate < 0 && rotationX+rotationXChange < this.rotationX2) || (this.rotationXRate > 0 && rotationX+rotationXChange > this.rotationX2)) - rotationX = this.rotationX2; - else if(particleAge >= this.rotationXRateStart) - rotationX += rotationXChange; - - float rotationYChange = this.rotationYRate / (float)particleMaxAge; - if((this.rotationYRate < 0 && rotationY+rotationYChange < this.rotationY2) || (this.rotationYRate > 0 && rotationY+rotationYChange > this.rotationY2)) - rotationY = this.rotationY2; - else if(particleAge >= this.rotationYRateStart) - rotationY += rotationYChange; - - float rotationZChange = this.rotationZRate / (float)particleMaxAge; - if((this.rotationZRate < 0 && rotationZ+rotationZChange < this.rotationZ2) || (this.rotationZRate > 0 && rotationZ+rotationZChange > this.rotationZ2)) - rotationZ = this.rotationZ2; - else if(particleAge >= this.rotationZRateStart) - rotationZ += rotationZChange; - - float u1 = 0.0f; - float u2 = 1.0f; - float v1 = 0.0f; - float v2 = 1.0f; - - float renderScale = 0.1F * particleScale; - - float posX = (float)(((prevPosX + (this.posX - prevPosX) * (double)partialTick) - interpPosX) + startX); - float posY = (float)(((prevPosY + (this.posY - prevPosY) * (double)partialTick) - interpPosY) + startY); - float posZ = (float)(((prevPosZ + (this.posZ - prevPosZ) * (double)partialTick) - interpPosZ) + startZ); - GL11.glTranslated((double)posX, (double)posY, (double)posZ); - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - double yaw = (player.rotationYaw/180)*Math.PI; - double pitch = (player.rotationPitch/180)*Math.PI; - if(facePlayer) { - if (Math.abs(rotationX % 360) >= 90 && Math.abs(rotationX % 360) < 270) { - rotationX += 180 * Math.signum(rotationX); - } - if (Math.abs(rotationY % 360) >= 90 && Math.abs(rotationY % 360) < 270) { - rotationY += 180 * Math.signum(rotationY); - } - GL11.glRotated(rotationX, Math.cos(yaw) * Math.cos(pitch), 0.0, Math.sin(yaw) * Math.cos(pitch)); GL11.glRotated(rotationY, -Math.sin(yaw) * Math.sin(pitch), Math.cos(pitch), Math.cos(yaw) * Math.sin(pitch)); GL11.glRotated(rotationZ, Math.sin(yaw) * Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw) * Math.cos(pitch)); @@ -200,11 +193,6 @@ public class EntityCustomFX extends EntityFX { GL11.glRotated(rotationZ, Math.sin(yaw), 0.0, -Math.cos(yaw)); GL11.glRotated((90 - player.rotationPitch), Math.cos(yaw), 0.0, Math.sin(yaw)); } - /* - if(Minecraft.getMinecraft().currentScreen == null){ - System.out.println(); - } - */ tessellator.startDrawingQuads(); tessellator.setBrightness(240); @@ -214,7 +202,33 @@ public class EntityCustomFX extends EntityFX { tessellator.addVertexWithUV(( - cosYaw * renderScale) + sinSinPitch * renderScale, + cosPitch * renderScale, ( - sinYaw * renderScale) + cosSinPitch * renderScale, u2, v1); tessellator.addVertexWithUV( + cosYaw * renderScale + sinSinPitch * renderScale, + cosPitch * renderScale, + sinYaw * renderScale + cosSinPitch * renderScale, u1, v1); tessellator.addVertexWithUV(( + cosYaw * renderScale) - sinSinPitch * renderScale, - cosPitch * renderScale, ( + sinYaw * renderScale) - cosSinPitch * renderScale, u1, v2); + tessellator.draw(); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + ClientProxy.bindTexture(location); + GL11.glTranslated((double)posX, (double)posY, (double)posZ); + + if(facePlayer) { + GL11.glRotated(rotationX, Math.cos(yaw) * Math.cos(pitch), 0.0, Math.sin(yaw) * Math.cos(pitch)); + GL11.glRotated(180 + rotationY, -Math.sin(yaw) * Math.sin(pitch), Math.cos(pitch), Math.cos(yaw) * Math.sin(pitch)); + GL11.glRotated(rotationZ, Math.sin(yaw) * Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw) * Math.cos(pitch)); + } else { + GL11.glRotated(player.rotationYaw % 360, 0.0, 1.0, 0.0); + GL11.glRotated(rotationY + 180, 0.0, 1.0, 0.0); + GL11.glRotated(180 - rotationX, Math.cos(yaw), 0.0, Math.sin(yaw)); + GL11.glRotated(rotationZ, Math.sin(yaw), 0.0, -Math.cos(yaw)); + GL11.glRotated((90 - player.rotationPitch), Math.cos(yaw), 0.0, Math.sin(yaw)); + } + + tessellator.startDrawingQuads(); + tessellator.setBrightness(240); + tessellator.setColorOpaque_F(1, 1, 1); + tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha); + tessellator.addVertexWithUV( - cosYaw * renderScale - sinSinPitch * renderScale, - cosPitch * renderScale, - sinYaw * renderScale - cosSinPitch * renderScale, u2, v2); + tessellator.addVertexWithUV(( - cosYaw * renderScale) + sinSinPitch * renderScale, + cosPitch * renderScale, ( - sinYaw * renderScale) + cosSinPitch * renderScale, u2, v1); + tessellator.addVertexWithUV( + cosYaw * renderScale + sinSinPitch * renderScale, + cosPitch * renderScale, + sinYaw * renderScale + cosSinPitch * renderScale, u1, v1); + tessellator.addVertexWithUV(( + cosYaw * renderScale) - sinSinPitch * renderScale, - cosPitch * renderScale, ( + sinYaw * renderScale) - cosSinPitch * renderScale, u1, v2); tessellator.draw(); GL11.glPopMatrix(); From d6c46158f5d474dc35d049a3e187dc86d2cd7c45 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 4 May 2022 23:08:30 -0500 Subject: [PATCH 16/75] TexturedRect classes for GUIs & overlays, and Custom GUI buttons now support textures of all sizes when using URLs. EntityCustomFX: -Added URL support --- .../java/noppes/npcs/client/fx/EntityCustomFX.java | 10 ++++++++++ .../client/gui/custom/components/CustomGuiButton.java | 2 +- .../gui/custom/components/CustomGuiTexturedRect.java | 2 +- .../components/CustomOverlayTexturedRect.java | 2 +- .../npcs/client/renderer/ImageBufferDownloadAlt.java | 9 ++++++++- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java index 92b2e4014..339116806 100644 --- a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java +++ b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java @@ -3,10 +3,15 @@ package noppes.npcs.client.fx; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.ITextureObject; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.resources.SkinManager; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import noppes.npcs.client.ClientProxy; +import noppes.npcs.client.ImageDownloadAlt; +import noppes.npcs.client.renderer.ImageBufferDownloadAlt; import org.lwjgl.opengl.GL11; public class EntityCustomFX extends EntityFX { @@ -118,6 +123,11 @@ public class EntityCustomFX extends EntityFX { } location = new ResourceLocation(directory); + if(directory.startsWith("https://")){ + TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); + ITextureObject object = new ImageDownloadAlt(null, directory, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false)); + texturemanager.loadTexture(this.location, object); + } this.facePlayer = facePlayer; } diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiButton.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiButton.java index b2d73a5cd..a51ce5f45 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiButton.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiButton.java @@ -53,7 +53,7 @@ public class CustomGuiButton extends GuiButton implements IClickListener { if(texture.startsWith("https://")){ TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - ITextureObject object = new ImageDownloadAlt(null, texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false)); + ITextureObject object = new ImageDownloadAlt(null, texture, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false)); texturemanager.loadTexture(this.texture, object); } } diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java index 4c9a56ab3..163ed6b37 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java @@ -57,7 +57,7 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent { if(texture.startsWith("https://")){ TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - ITextureObject object = new ImageDownloadAlt(null, texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false)); + ITextureObject object = new ImageDownloadAlt(null, texture, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false)); texturemanager.loadTexture(this.texture, object); } } diff --git a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayTexturedRect.java b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayTexturedRect.java index 06867b921..2a6367815 100644 --- a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayTexturedRect.java +++ b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayTexturedRect.java @@ -55,7 +55,7 @@ public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent if(texture.startsWith("https://")){ TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - ITextureObject object = new ImageDownloadAlt(null, texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false)); + ITextureObject object = new ImageDownloadAlt(null, texture, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false)); texturemanager.loadTexture(this.texture, object); } } diff --git a/src/main/java/noppes/npcs/client/renderer/ImageBufferDownloadAlt.java b/src/main/java/noppes/npcs/client/renderer/ImageBufferDownloadAlt.java index 5ff467ac4..ca25d7008 100644 --- a/src/main/java/noppes/npcs/client/renderer/ImageBufferDownloadAlt.java +++ b/src/main/java/noppes/npcs/client/renderer/ImageBufferDownloadAlt.java @@ -12,12 +12,18 @@ public class ImageBufferDownloadAlt extends ImageBufferDownload { private int imageWidth; private int imageHeight; private boolean version; + public boolean skinTexture = true; // If Version == true, use 64 Loader public ImageBufferDownloadAlt(boolean ver){ this.version = ver; } + public ImageBufferDownloadAlt(boolean ver, boolean skinTexture){ + this.version = ver; + this.skinTexture = skinTexture; + } + @Override public BufferedImage parseUserSkin(BufferedImage bufferedimage) { @@ -31,7 +37,8 @@ public class ImageBufferDownloadAlt extends ImageBufferDownload { g.dispose(); imageData = ((DataBufferInt) bufferedimage1.getRaster().getDataBuffer()).getData(); - setAreaTransparent(imageWidth / 2, 0, imageWidth, imageHeight / 4); + if(skinTexture) + setAreaTransparent(imageWidth / 2, 0, imageWidth, imageHeight / 4); return bufferedimage1; } From 728269ff87b94361864547b74ea30cc4d7f2c240 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Fri, 6 May 2022 00:22:28 -0500 Subject: [PATCH 17/75] ScriptEntityParticle: -Added width, offset, and animation rate attributes to particles. -Added setSize(), getWidth() and getHeight() functions. -Added setOffset(), getOffsetX(), and getOffsetY() functions. -Added setAnimRate() and getAnimRate() functions. --- .../java/noppes/npcs/NoppesUtilServer.java | 4 +- .../noppes/npcs/client/ImageDownloadAlt.java | 4 + .../java/noppes/npcs/client/NoppesUtil.java | 9 +- .../noppes/npcs/client/fx/EntityCustomFX.java | 221 ++++++++++++------ .../npcs/scripted/ScriptEntityParticle.java | 23 +- .../npcs/scripted/entity/ScriptEntity.java | 12 +- 6 files changed, 191 insertions(+), 82 deletions(-) diff --git a/src/main/java/noppes/npcs/NoppesUtilServer.java b/src/main/java/noppes/npcs/NoppesUtilServer.java index 2141f5d83..278878640 100644 --- a/src/main/java/noppes/npcs/NoppesUtilServer.java +++ b/src/main/java/noppes/npcs/NoppesUtilServer.java @@ -320,7 +320,7 @@ public class NoppesUtilServer { float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart, float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart, float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart, - boolean facePlayer, + boolean facePlayer, int width, int height, int offsetX, int offsetY, int animRate, int entityID ){ Server.sendToAll(EnumPacketClient.SCRIPTED_PARTICLE, @@ -332,7 +332,7 @@ public class NoppesUtilServer { rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, - facePlayer, + facePlayer, width, height, offsetX, offsetY, animRate, entityID ); } diff --git a/src/main/java/noppes/npcs/client/ImageDownloadAlt.java b/src/main/java/noppes/npcs/client/ImageDownloadAlt.java index f32e81c3b..88338c744 100644 --- a/src/main/java/noppes/npcs/client/ImageDownloadAlt.java +++ b/src/main/java/noppes/npcs/client/ImageDownloadAlt.java @@ -76,6 +76,10 @@ public class ImageDownloadAlt extends SimpleTexture } } + public BufferedImage getBufferedImage(){ + return this.bufferedImage; + } + public void loadTexture(IResourceManager resourceManager) throws IOException { if (this.bufferedImage == null && this.textureLocation != null) diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index 035478c4d..3b2d1f27a 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -115,6 +115,12 @@ public class NoppesUtil { boolean facePlayer = buffer.readBoolean(); + int width = buffer.readInt(); + int height = buffer.readInt(); + int offsetX = buffer.readInt(); + int offsetY = buffer.readInt(); + int animRate = buffer.readInt(); + int entityID = buffer.readInt(); World worldObj = Minecraft.getMinecraft().theWorld; @@ -133,7 +139,8 @@ public class NoppesUtil { rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, - maxAge, facePlayer + maxAge, facePlayer, + width, height, offsetX, offsetY, animRate ); for(int i = 0; i < amount; i++){ diff --git a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java index 339116806..421c4da14 100644 --- a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java +++ b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java @@ -5,7 +5,10 @@ import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.ITextureObject; import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.client.resources.IResource; import net.minecraft.client.resources.SkinManager; +import net.minecraft.client.resources.data.TextureMetadataSection; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; @@ -14,6 +17,11 @@ import noppes.npcs.client.ImageDownloadAlt; import noppes.npcs.client.renderer.ImageBufferDownloadAlt; import org.lwjgl.opengl.GL11; +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; + public class EntityCustomFX extends EntityFX { private Entity entity; private final ResourceLocation location; @@ -51,6 +59,19 @@ public class EntityCustomFX extends EntityFX { public boolean facePlayer = true; + private int totalWidth, totalHeight; + public int width, height; + public int offsetX, offsetY; + + private int timeSinceStart; + public int animRate; + public int animPosX; + public int animPosY; + + private ImageDownloadAlt imageDownloadAlt = null; + private boolean isUrl = false; + private boolean gotWidthHeight = false; + public EntityCustomFX(Entity entity, String directory, int HEXColor, double x, double y, double z, double motionX, double motionY, double motionZ, float gravity, float scale1, float scale2, float scaleRate, int scaleRateStart, @@ -58,7 +79,7 @@ public class EntityCustomFX extends EntityFX { float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart, float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart, float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart, - int age, boolean facePlayer) { + int age, boolean facePlayer, int width, int height, int offsetX, int offsetY, int animRate) { super(entity.worldObj, x, y, z, motionX, motionY, motionZ); this.scale1 = scale1; @@ -123,19 +144,67 @@ public class EntityCustomFX extends EntityFX { } location = new ResourceLocation(directory); + + this.width = width; + this.height = height; + this.offsetX = offsetX; + this.offsetY = offsetY; + this.animRate = animRate; + if(directory.startsWith("https://")){ + isUrl = true; TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - ITextureObject object = new ImageDownloadAlt(null, directory, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false)); - texturemanager.loadTexture(this.location, object); + imageDownloadAlt = new ImageDownloadAlt(null, directory, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false)); + texturemanager.loadTexture(this.location, imageDownloadAlt); + } else { + try { + getWidthHeight(); + } catch (IOException e) { + e.printStackTrace(); + } } this.facePlayer = facePlayer; } - @Override + @Override + public void onUpdate() { + ++this.timeSinceStart; + + if (this.timeSinceStart == this.particleMaxAge) + { + this.setDead(); + } + + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + this.motionY -= 0.04D * (double)this.particleGravity; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + + if(animRate > 0 && timeSinceStart%animRate == 0 && timeSinceStart > 0 && gotWidthHeight){ + animPosX += width; + if(animPosX + width > totalWidth) { + animPosX = offsetX; + animPosY += height; + if(animPosY > totalHeight) { + animPosY = offsetY; + } + } + } + } + + @Override public void renderParticle(Tessellator tessellator, float partialTick, float cosYaw, float cosPitch, float sinYaw, float sinSinPitch, float cosSinPitch) { tessellator.draw(); + ClientProxy.bindTexture(location); + GL11.glDisable(GL11.GL_BLEND); + + if(imageDownloadAlt != null && isUrl && !gotWidthHeight){ + getURLWidthHeight(); + } if(move){ startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTick); @@ -173,79 +242,87 @@ public class EntityCustomFX extends EntityFX { else if(particleAge >= this.rotationZRateStart) rotationZ += rotationZChange; - float u1 = 0.0f; - float u2 = 1.0f; - float v1 = 0.0f; - float v2 = 1.0f; - - float renderScale = 0.1F * particleScale; - - float posX = (float)(((prevPosX + (this.posX - prevPosX) * (double)partialTick) - interpPosX) + startX); - float posY = (float)(((prevPosY + (this.posY - prevPosY) * (double)partialTick) - interpPosY) + startY); - float posZ = (float)(((prevPosZ + (this.posZ - prevPosZ) * (double)partialTick) - interpPosZ) + startZ); - - EntityPlayer player = Minecraft.getMinecraft().thePlayer; - double yaw = (player.rotationYaw/180)*Math.PI; - double pitch = (player.rotationPitch/180)*Math.PI; - - GL11.glPushMatrix(); - ClientProxy.bindTexture(location); - GL11.glTranslated((double)posX, (double)posY, (double)posZ); - - if(facePlayer) { - GL11.glRotated(rotationX, Math.cos(yaw) * Math.cos(pitch), 0.0, Math.sin(yaw) * Math.cos(pitch)); - GL11.glRotated(rotationY, -Math.sin(yaw) * Math.sin(pitch), Math.cos(pitch), Math.cos(yaw) * Math.sin(pitch)); - GL11.glRotated(rotationZ, Math.sin(yaw) * Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw) * Math.cos(pitch)); - } else { - GL11.glRotated(player.rotationYaw % 360, 0.0, 1.0, 0.0); - GL11.glRotated(rotationY, 0.0, 1.0, 0.0); - GL11.glRotated(rotationX, Math.cos(yaw), 0.0, Math.sin(yaw)); - GL11.glRotated(rotationZ, Math.sin(yaw), 0.0, -Math.cos(yaw)); - GL11.glRotated((90 - player.rotationPitch), Math.cos(yaw), 0.0, Math.sin(yaw)); - } - - tessellator.startDrawingQuads(); - tessellator.setBrightness(240); - tessellator.setColorOpaque_F(1, 1, 1); - tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha); - tessellator.addVertexWithUV( - cosYaw * renderScale - sinSinPitch * renderScale, - cosPitch * renderScale, - sinYaw * renderScale - cosSinPitch * renderScale, u2, v2); - tessellator.addVertexWithUV(( - cosYaw * renderScale) + sinSinPitch * renderScale, + cosPitch * renderScale, ( - sinYaw * renderScale) + cosSinPitch * renderScale, u2, v1); - tessellator.addVertexWithUV( + cosYaw * renderScale + sinSinPitch * renderScale, + cosPitch * renderScale, + sinYaw * renderScale + cosSinPitch * renderScale, u1, v1); - tessellator.addVertexWithUV(( + cosYaw * renderScale) - sinSinPitch * renderScale, - cosPitch * renderScale, ( + sinYaw * renderScale) - cosSinPitch * renderScale, u1, v2); - tessellator.draw(); - GL11.glPopMatrix(); - - GL11.glPushMatrix(); - ClientProxy.bindTexture(location); - GL11.glTranslated((double)posX, (double)posY, (double)posZ); - - if(facePlayer) { - GL11.glRotated(rotationX, Math.cos(yaw) * Math.cos(pitch), 0.0, Math.sin(yaw) * Math.cos(pitch)); - GL11.glRotated(180 + rotationY, -Math.sin(yaw) * Math.sin(pitch), Math.cos(pitch), Math.cos(yaw) * Math.sin(pitch)); - GL11.glRotated(rotationZ, Math.sin(yaw) * Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw) * Math.cos(pitch)); - } else { - GL11.glRotated(player.rotationYaw % 360, 0.0, 1.0, 0.0); - GL11.glRotated(rotationY + 180, 0.0, 1.0, 0.0); - GL11.glRotated(180 - rotationX, Math.cos(yaw), 0.0, Math.sin(yaw)); - GL11.glRotated(rotationZ, Math.sin(yaw), 0.0, -Math.cos(yaw)); - GL11.glRotated((90 - player.rotationPitch), Math.cos(yaw), 0.0, Math.sin(yaw)); - } - - tessellator.startDrawingQuads(); - tessellator.setBrightness(240); - tessellator.setColorOpaque_F(1, 1, 1); - tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha); - tessellator.addVertexWithUV( - cosYaw * renderScale - sinSinPitch * renderScale, - cosPitch * renderScale, - sinYaw * renderScale - cosSinPitch * renderScale, u2, v2); - tessellator.addVertexWithUV(( - cosYaw * renderScale) + sinSinPitch * renderScale, + cosPitch * renderScale, ( - sinYaw * renderScale) + cosSinPitch * renderScale, u2, v1); - tessellator.addVertexWithUV( + cosYaw * renderScale + sinSinPitch * renderScale, + cosPitch * renderScale, + sinYaw * renderScale + cosSinPitch * renderScale, u1, v1); - tessellator.addVertexWithUV(( + cosYaw * renderScale) - sinSinPitch * renderScale, - cosPitch * renderScale, ( + sinYaw * renderScale) - cosSinPitch * renderScale, u1, v2); - tessellator.draw(); - GL11.glPopMatrix(); + renderParticleSide(true, tessellator, partialTick); + renderParticleSide(false, tessellator, partialTick); GL11.glColor4f(1, 1, 1, 1.0F); ClientProxy.bindTexture(resource); tessellator.startDrawingQuads(); } + + public void renderParticleSide(boolean front, Tessellator tessellator, float partialTick){ + float u1 = (float)offsetX/(float)totalWidth + (float)animPosX/(float)totalWidth; + float u2 = u1 + (float)width/(float)totalWidth; + float v1 = (float)offsetY/(float)totalHeight + (float)animPosY/(float)totalHeight; + float v2 = v1 + (float)height/(float)totalHeight; + + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + float renderScale = 0.1F * particleScale; + float posX = (float)(((prevPosX + (this.posX - prevPosX) * (double)partialTick) - interpPosX) + startX); + float posY = (float)(((prevPosY + (this.posY - prevPosY) * (double)partialTick) - interpPosY) + startY); + float posZ = (float)(((prevPosZ + (this.posZ - prevPosZ) * (double)partialTick) - interpPosZ) + startZ); + + GL11.glPushMatrix(); + GL11.glTranslated(posX,posY,posZ); + GL11.glScalef(renderScale, renderScale, renderScale); + if(facePlayer) { + GL11.glRotated(180 - player.rotationYaw, 0.0, 1.0, 0.0); + GL11.glRotated(-player.rotationPitch + 90, 1.0, 0.0, 0.0); + + GL11.glRotated(rotationX, 1.0, 0.0, 0.0); + GL11.glRotated(rotationZ, 0.0, 1.0, 0.0); + GL11.glRotated(rotationY + (!front ? 180 : 0), 0.0, 0.0, 1.0); + } else { + GL11.glRotated(rotationX, 1.0, 0.0, 0.0); + GL11.glRotated(rotationY, 0.0, 1.0, 0.0); + GL11.glRotated(rotationZ + (!front ? 180 : 0), 0.0, 0.0, 1.0); + } + + tessellator.startDrawingQuads(); + tessellator.setBrightness(240); + tessellator.setColorOpaque_F(1, 1, 1); + tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha); + tessellator.addVertexWithUV( (u2-u1)/2, 0, (v2-v1)/2, u2, v2); + tessellator.addVertexWithUV( (u2-u1)/2, 0, -(v2-v1)/2, u2, v1); + tessellator.addVertexWithUV( -(u2-u1)/2, 0, -(v2-v1)/2, u1, v1); + tessellator.addVertexWithUV( -(u2-u1)/2, 0, (v2-v1)/2, u1, v2); + tessellator.draw(); + GL11.glPopMatrix(); + } + + public void getWidthHeight() throws IOException { + InputStream inputstream = null; + + try { + IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(location); + inputstream = iresource.getInputStream(); + BufferedImage bufferedimage = ImageIO.read(inputstream); + gotWidthHeight = true; + this.totalWidth = bufferedimage.getWidth(); + this.totalHeight = bufferedimage.getHeight(); + correctWidthHeight(); + } finally { + if (inputstream != null) { + inputstream.close(); + } + } + } + + public void getURLWidthHeight(){ + if(imageDownloadAlt.getBufferedImage() != null) { + gotWidthHeight = true; + this.totalWidth = imageDownloadAlt.getBufferedImage().getWidth(); + this.totalHeight = imageDownloadAlt.getBufferedImage().getHeight(); + correctWidthHeight(); + } + } + + public void correctWidthHeight(){ + totalWidth = Math.max(totalWidth, 1); + totalHeight = Math.max(totalHeight, 1); + this.width = width < 0 ? totalWidth : width; + this.height = height < 0 ? totalHeight : height; + } public int getFXLayer(){ return 0; diff --git a/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java b/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java index c81aac693..af51270e4 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java +++ b/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java @@ -33,6 +33,10 @@ public class ScriptEntityParticle { public float rotationZRate = 0.0F; public int rotationZRateStart = 0; + public int width = -1, height = -1; + public int offsetX = 0, offsetY = 0; + public int animRate = 0; + public boolean facePlayer = true; public ScriptEntityParticle(String directory){ @@ -49,11 +53,28 @@ public class ScriptEntityParticle { rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, - facePlayer, + facePlayer, width, height, offsetX, offsetY, animRate, entityID ); } + public void setSize(int width, int height){ + this.width = width; + this.height = height; + } + public int getWidth() { return width; } + public int getHeight() { return height; } + + public void setOffset(int offsetX, int offsetY){ + this.offsetX = offsetX; + this.offsetY = offsetY; + } + public int getOffsetX() { return offsetX; } + public int getOffsetY() { return offsetY; } + + public void setAnimRate(int animRate) { this.animRate = animRate; } + public int getAnimRate() { return animRate; } + public boolean getFacePlayer() { return facePlayer; } public void setFacePlayer(boolean facePlayer) { this.facePlayer = facePlayer; } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index 09bb5b4dc..8a83eb4ac 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -82,7 +82,7 @@ public class ScriptEntity implements IEntity { rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, - true, + true, -1, -1, 0,0, 0, entityID ); } @@ -101,7 +101,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - true, + true, -1, -1, 0,0,0, entityID ); } @@ -119,7 +119,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - true, + true, -1, -1, 0,0,0, entityID ); } @@ -136,7 +136,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - true, + true, -1, -1, 0,0,0, entityID ); } @@ -152,7 +152,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - true, + true, -1, -1, 0,0,0, entityID ); } @@ -167,7 +167,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - true, + true, -1, -1, 0,0,0, entityID ); } From 2d2933e873676fcd6d038b92b12597512f0b1822 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Fri, 6 May 2022 01:22:48 -0500 Subject: [PATCH 18/75] ScriptEntityParticle: -Particles can now start or end at a certain tick, and loop or not loop. -Added setSize(), getWidth() and getHeight() functions. -Added setOffset(), getOffsetX(), and getOffsetY() functions. -Added setAnimRate() and getAnimRate() functions. --- .../java/noppes/npcs/NoppesUtilServer.java | 6 +++-- .../java/noppes/npcs/client/NoppesUtil.java | 7 +++++- .../noppes/npcs/client/fx/EntityCustomFX.java | 22 ++++++++++++++----- .../npcs/scripted/ScriptEntityParticle.java | 18 ++++++++++++++- .../npcs/scripted/entity/ScriptEntity.java | 18 ++++++++++----- 5 files changed, 55 insertions(+), 16 deletions(-) diff --git a/src/main/java/noppes/npcs/NoppesUtilServer.java b/src/main/java/noppes/npcs/NoppesUtilServer.java index 278878640..ba4c50d5f 100644 --- a/src/main/java/noppes/npcs/NoppesUtilServer.java +++ b/src/main/java/noppes/npcs/NoppesUtilServer.java @@ -320,7 +320,8 @@ public class NoppesUtilServer { float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart, float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart, float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart, - boolean facePlayer, int width, int height, int offsetX, int offsetY, int animRate, + boolean facePlayer, int width, int height, int offsetX, int offsetY, + int animRate, boolean animLoop, int animStart, int animEnd, int entityID ){ Server.sendToAll(EnumPacketClient.SCRIPTED_PARTICLE, @@ -332,7 +333,8 @@ public class NoppesUtilServer { rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, - facePlayer, width, height, offsetX, offsetY, animRate, + facePlayer, width, height, offsetX, offsetY, + animRate, animLoop, animStart, animEnd, entityID ); } diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index 3b2d1f27a..5552bbea3 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -119,7 +119,11 @@ public class NoppesUtil { int height = buffer.readInt(); int offsetX = buffer.readInt(); int offsetY = buffer.readInt(); + int animRate = buffer.readInt(); + boolean animLoop = buffer.readBoolean(); + int animStart = buffer.readInt(); + int animEnd = buffer.readInt(); int entityID = buffer.readInt(); @@ -140,7 +144,8 @@ public class NoppesUtil { rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, maxAge, facePlayer, - width, height, offsetX, offsetY, animRate + width, height, offsetX, offsetY, + animRate, animLoop, animStart, animEnd ); for(int i = 0; i < amount; i++){ diff --git a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java index 421c4da14..0fb47c7d2 100644 --- a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java +++ b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java @@ -65,8 +65,10 @@ public class EntityCustomFX extends EntityFX { private int timeSinceStart; public int animRate; - public int animPosX; - public int animPosY; + public boolean animLoop; + public int animStart,animEnd; + private int animPosX; + private int animPosY; private ImageDownloadAlt imageDownloadAlt = null; private boolean isUrl = false; @@ -79,7 +81,9 @@ public class EntityCustomFX extends EntityFX { float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart, float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart, float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart, - int age, boolean facePlayer, int width, int height, int offsetX, int offsetY, int animRate) { + int age, boolean facePlayer, int width, int height, int offsetX, int offsetY, + int animRate, boolean animLoop, int animStart, int animEnd + ) { super(entity.worldObj, x, y, z, motionX, motionY, motionZ); this.scale1 = scale1; @@ -149,7 +153,13 @@ public class EntityCustomFX extends EntityFX { this.height = height; this.offsetX = offsetX; this.offsetY = offsetY; + this.animRate = animRate; + this.animLoop = animLoop; + this.animStart = animStart; + this.animEnd = animEnd; + if(this.animEnd < this.animStart) + this.animEnd = this.animStart + this.particleMaxAge; if(directory.startsWith("https://")){ isUrl = true; @@ -183,12 +193,12 @@ public class EntityCustomFX extends EntityFX { this.motionY -= 0.04D * (double)this.particleGravity; this.moveEntity(this.motionX, this.motionY, this.motionZ); - if(animRate > 0 && timeSinceStart%animRate == 0 && timeSinceStart > 0 && gotWidthHeight){ + if(animRate > 0 && timeSinceStart%animRate == 0 && timeSinceStart > 0 && gotWidthHeight && timeSinceStart >= animStart && timeSinceStart <= animEnd && (animLoop || animPosY <= totalHeight)){ animPosX += width; - if(animPosX + width > totalWidth) { + if (animPosX + width > totalWidth) { animPosX = offsetX; animPosY += height; - if(animPosY > totalHeight) { + if (animPosY > totalHeight && animLoop) { animPosY = offsetY; } } diff --git a/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java b/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java index af51270e4..3a403d9d3 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java +++ b/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java @@ -35,7 +35,10 @@ public class ScriptEntityParticle { public int width = -1, height = -1; public int offsetX = 0, offsetY = 0; + public int animRate = 0; + public boolean animLoop = true; + public int animStart = 0, animEnd = -1; public boolean facePlayer = true; @@ -53,7 +56,8 @@ public class ScriptEntityParticle { rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, - facePlayer, width, height, offsetX, offsetY, animRate, + facePlayer, width, height, offsetX, offsetY, + animRate, animLoop, animStart, animEnd, entityID ); } @@ -72,8 +76,20 @@ public class ScriptEntityParticle { public int getOffsetX() { return offsetX; } public int getOffsetY() { return offsetY; } + public void setAnim(int animRate, boolean animLoop, int animStart, int animEnd){ + this.animRate = animRate; + this.animLoop = animLoop; + this.animStart = animStart; + this.animEnd = animEnd; + } public void setAnimRate(int animRate) { this.animRate = animRate; } public int getAnimRate() { return animRate; } + public void setAnimLoop(boolean animLoop) { this.animLoop = animLoop; } + public boolean getAnimLoop() { return animLoop; } + public void setAnimStart(int animStart) { this.animStart = animStart; } + public int getAnimStart() { return animStart; } + public void setAnimEnd(int animEnd) { this.animEnd = animEnd; } + public int getAnimEnd() { return animEnd; } public boolean getFacePlayer() { return facePlayer; } public void setFacePlayer(boolean facePlayer) { this.facePlayer = facePlayer; } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index 8a83eb4ac..6fe0faa58 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -82,7 +82,8 @@ public class ScriptEntity implements IEntity { rotationX1, rotationX2, rotationXRate, rotationXRateStart, rotationY1, rotationY2, rotationYRate, rotationYRateStart, rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, - true, -1, -1, 0,0, 0, + true, -1, -1, 0,0, + 0, true, 0, 0, entityID ); } @@ -101,7 +102,8 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - true, -1, -1, 0,0,0, + true, -1, -1, 0,0, + 0, true, 0, 0, entityID ); } @@ -119,7 +121,8 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - true, -1, -1, 0,0,0, + true, -1, -1, 0,0, + 0, true, 0, 0, entityID ); } @@ -136,7 +139,8 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - true, -1, -1, 0,0,0, + true, -1, -1, 0,0, + 0, true, 0, 0, entityID ); } @@ -152,7 +156,8 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - true, -1, -1, 0,0,0, + true, -1, -1, 0,0, + 0, true, 0, 0, entityID ); } @@ -167,7 +172,8 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - true, -1, -1, 0,0,0, + true, -1, -1, 0,0, + 0, true, 0, 0, entityID ); } From dbc9754b43bb04da65cc559a01b96471b7e7b661 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Fri, 6 May 2022 03:15:18 -0500 Subject: [PATCH 19/75] Re-enabled OpenGL blending for custom particles --- src/main/java/noppes/npcs/client/fx/EntityCustomFX.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java index 0fb47c7d2..ef57f9b8d 100644 --- a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java +++ b/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java @@ -210,7 +210,6 @@ public class EntityCustomFX extends EntityFX { { tessellator.draw(); ClientProxy.bindTexture(location); - GL11.glDisable(GL11.GL_BLEND); if(imageDownloadAlt != null && isUrl && !gotWidthHeight){ getURLWidthHeight(); From c3b9096295ad1af5f2a25a2e2e82ac66a4959bc0 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Fri, 6 May 2022 03:38:24 -0500 Subject: [PATCH 20/75] Scripted particles can now spawn anywhere in the world, not just attached to an entity. ScriptEntityParticle renamed to ScriptParticle, and EntityCustomFX renamed to CustomFX. Re-enabled OpenGL blending for custom particles. --- .../java/noppes/npcs/client/NoppesUtil.java | 10 ++--- .../fx/{EntityCustomFX.java => CustomFX.java} | 40 ++++++++----------- .../java/noppes/npcs/scripted/NpcAPI.java | 7 ++-- ...ntityParticle.java => ScriptParticle.java} | 19 ++++++++- .../noppes/npcs/scripted/ScriptWorld.java | 6 +-- .../npcs/scripted/entity/ScriptEntity.java | 3 +- .../npcs/scripted/interfaces/IWorld.java | 5 +-- .../npcs/scripted/wrapper/WrapperNpcAPI.java | 8 +++- 8 files changed, 50 insertions(+), 48 deletions(-) rename src/main/java/noppes/npcs/client/fx/{EntityCustomFX.java => CustomFX.java} (88%) rename src/main/java/noppes/npcs/scripted/{ScriptEntityParticle.java => ScriptParticle.java} (92%) diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index 5552bbea3..78636bae7 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -6,7 +6,6 @@ import java.io.File; import java.io.IOException; import java.net.URI; import java.util.HashMap; -import java.util.List; import java.util.Random; import java.util.Vector; @@ -23,7 +22,7 @@ import net.minecraft.world.World; import noppes.npcs.CustomNpcs; import noppes.npcs.NoppesUtilPlayer; import noppes.npcs.Server; -import noppes.npcs.client.fx.EntityCustomFX; +import noppes.npcs.client.fx.CustomFX; import noppes.npcs.client.gui.player.GuiDialogInteract; import noppes.npcs.client.gui.player.GuiQuestCompletion; import noppes.npcs.client.gui.util.GuiContainerNPCInterface; @@ -130,11 +129,8 @@ public class NoppesUtil { World worldObj = Minecraft.getMinecraft().theWorld; Entity entity = worldObj.getEntityByID(entityID); - if(entity == null) - return; - - EntityCustomFX fx = new EntityCustomFX( - entity, + CustomFX fx = new CustomFX( + worldObj, entity, directory, HEXcolor, x, y, z, motionX, motionY, motionZ, gravity, diff --git a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java b/src/main/java/noppes/npcs/client/fx/CustomFX.java similarity index 88% rename from src/main/java/noppes/npcs/client/fx/EntityCustomFX.java rename to src/main/java/noppes/npcs/client/fx/CustomFX.java index ef57f9b8d..ad7292759 100644 --- a/src/main/java/noppes/npcs/client/fx/EntityCustomFX.java +++ b/src/main/java/noppes/npcs/client/fx/CustomFX.java @@ -12,6 +12,7 @@ import net.minecraft.client.resources.data.TextureMetadataSection; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; import noppes.npcs.client.ClientProxy; import noppes.npcs.client.ImageDownloadAlt; import noppes.npcs.client.renderer.ImageBufferDownloadAlt; @@ -22,8 +23,8 @@ import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; -public class EntityCustomFX extends EntityFX { - private Entity entity; +public class CustomFX extends EntityFX { + private Entity entity = null; private final ResourceLocation location; private static final ResourceLocation resource = new ResourceLocation("textures/particle/particles.png"); private boolean move = true; @@ -74,17 +75,17 @@ public class EntityCustomFX extends EntityFX { private boolean isUrl = false; private boolean gotWidthHeight = false; - public EntityCustomFX(Entity entity, String directory, int HEXColor, double x, double y, double z, - double motionX, double motionY, double motionZ, float gravity, - float scale1, float scale2, float scaleRate, int scaleRateStart, - float alpha1, float alpha2, float alphaRate, int alphaRateStart, - float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart, - float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart, - float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart, - int age, boolean facePlayer, int width, int height, int offsetX, int offsetY, - int animRate, boolean animLoop, int animStart, int animEnd + public CustomFX(World worldObj, Entity entity, String directory, int HEXColor, double x, double y, double z, + double motionX, double motionY, double motionZ, float gravity, + float scale1, float scale2, float scaleRate, int scaleRateStart, + float alpha1, float alpha2, float alphaRate, int alphaRateStart, + float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart, + float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart, + float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart, + int age, boolean facePlayer, int width, int height, int offsetX, int offsetY, + int animRate, boolean animLoop, int animStart, int animEnd ) { - super(entity.worldObj, x, y, z, motionX, motionY, motionZ); + super(worldObj, x, y, z, motionX, motionY, motionZ); this.scale1 = scale1; this.scale2 = scale2; @@ -139,13 +140,6 @@ public class EntityCustomFX extends EntityFX { particleRed = (HEXColor >> 16 & 255) / 255f; particleGreen = (HEXColor >> 8 & 255) / 255f; particleBlue = (HEXColor & 255) / 255f; - - if(Math.floor(Math.random()*3) == 1){ - move = false; - this.startX = (float) entity.posX; - this.startY = (float) entity.posY; - this.startZ = (float) entity.posZ; - } location = new ResourceLocation(directory); @@ -215,7 +209,7 @@ public class EntityCustomFX extends EntityFX { getURLWidthHeight(); } - if(move){ + if(move && entity != null){ startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTick); startY = (float)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTick); startZ = (float)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTick); @@ -267,9 +261,9 @@ public class EntityCustomFX extends EntityFX { EntityPlayer player = Minecraft.getMinecraft().thePlayer; float renderScale = 0.1F * particleScale; - float posX = (float)(((prevPosX + (this.posX - prevPosX) * (double)partialTick) - interpPosX) + startX); - float posY = (float)(((prevPosY + (this.posY - prevPosY) * (double)partialTick) - interpPosY) + startY); - float posZ = (float)(((prevPosZ + (this.posZ - prevPosZ) * (double)partialTick) - interpPosZ) + startZ); + float posX = (float)((prevPosX + (this.posX - prevPosX) * (double)partialTick) - interpPosX) + startX; + float posY = (float)((prevPosY + (this.posY - prevPosY) * (double)partialTick) - interpPosY) + startY; + float posZ = (float)((prevPosZ + (this.posZ - prevPosZ) * (double)partialTick) - interpPosZ) + startZ; GL11.glPushMatrix(); GL11.glTranslated(posX,posY,posZ); diff --git a/src/main/java/noppes/npcs/scripted/NpcAPI.java b/src/main/java/noppes/npcs/scripted/NpcAPI.java index 3d49dc260..6c6fdcbbe 100644 --- a/src/main/java/noppes/npcs/scripted/NpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/NpcAPI.java @@ -10,11 +10,8 @@ import java.io.File; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.eventhandler.EventBus; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; @@ -91,7 +88,9 @@ public abstract class NpcAPI { public abstract ScriptItemStack createItem(String id, int damage, int size); - public abstract ScriptEntityParticle createEntityParticle(String directory); + public abstract ScriptParticle createParticle(String directory); + + public abstract ScriptParticle createEntityParticle(String directory); public abstract int getServerTime(); } diff --git a/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java b/src/main/java/noppes/npcs/scripted/ScriptParticle.java similarity index 92% rename from src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java rename to src/main/java/noppes/npcs/scripted/ScriptParticle.java index 3a403d9d3..3ece802b0 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptEntityParticle.java +++ b/src/main/java/noppes/npcs/scripted/ScriptParticle.java @@ -6,7 +6,7 @@ import noppes.npcs.scripted.entity.ScriptEntity; /** * Created by luisc on 9/8/2021. */ -public class ScriptEntityParticle { +public class ScriptParticle { private String directory; private int HEXcolor = 0xFFFFFF; private int amount = 1; @@ -42,7 +42,7 @@ public class ScriptEntityParticle { public boolean facePlayer = true; - public ScriptEntityParticle(String directory){ + public ScriptParticle(String directory){ this.directory = directory; } @@ -62,6 +62,21 @@ public class ScriptEntityParticle { ); } + public void spawnInWorld(double x, double y, double z){ + NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge, + x, y, z, + motionX, motionY, motionZ, gravity, + scale1, scale2, scaleRate, scaleRateStart, + alpha1, alpha2, alphaRate, alphaRateStart, + rotationX1, rotationX2, rotationXRate, rotationXRateStart, + rotationY1, rotationY2, rotationYRate, rotationYRateStart, + rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, + facePlayer, width, height, offsetX, offsetY, + animRate, animLoop, animStart, animEnd, + -1 + ); + } + public void setSize(int width, int height){ this.width = width; this.height = height; diff --git a/src/main/java/noppes/npcs/scripted/ScriptWorld.java b/src/main/java/noppes/npcs/scripted/ScriptWorld.java index e0dda6112..aad1a3fd4 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptWorld.java +++ b/src/main/java/noppes/npcs/scripted/ScriptWorld.java @@ -21,7 +21,6 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntitySign; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; import net.minecraft.world.WorldServer; import noppes.npcs.NoppesUtilServer; import noppes.npcs.blocks.tiles.TileBigSign; @@ -31,7 +30,6 @@ import noppes.npcs.scripted.entity.ScriptEntity; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.interfaces.IBlock; import noppes.npcs.scripted.interfaces.IWorld; -import sun.font.Script; public class ScriptWorld implements IWorld { private static Map tempData = new HashMap(); @@ -335,8 +333,8 @@ public class ScriptWorld implements IWorld { * @param directory The particle's texture directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/tail.png" * @return Returns ScriptEntityParticle object */ - public ScriptEntityParticle createEntityParticle(String directory){ - return new ScriptEntityParticle(directory); + public ScriptParticle createEntityParticle(String directory){ + return new ScriptParticle(directory); } /** diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index 6fe0faa58..819d834f3 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -16,7 +16,6 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTBase.NBTPrimitive; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagString; -import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; @@ -177,7 +176,7 @@ public class ScriptEntity implements IEntity { entityID ); } - public void spawnParticle(ScriptEntityParticle entityParticle) { entityParticle.spawnOnEntity(this); } + public void spawnParticle(ScriptParticle entityParticle) { entityParticle.spawnOnEntity(this); } public int getEntityId(){ return entity.getEntityId(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java index c378e6894..e11471d6b 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java @@ -1,9 +1,6 @@ package noppes.npcs.scripted.interfaces; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; import net.minecraft.world.WorldServer; import noppes.npcs.scripted.*; import noppes.npcs.scripted.entity.ScriptEntity; @@ -175,7 +172,7 @@ public interface IWorld { * @param directory The particle's texture directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/tail.png" * @return Returns ScriptEntityParticle object */ - public ScriptEntityParticle createEntityParticle(String directory); + public ScriptParticle createEntityParticle(String directory); /** * @param key Get temp data for this key diff --git a/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java b/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java index 5fb686421..3d2353aea 100644 --- a/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java @@ -283,8 +283,12 @@ public class WrapperNpcAPI extends NpcAPI { MinecraftServer.getServer().setMOTD(motd); } - public ScriptEntityParticle createEntityParticle(String directory){ - return new ScriptEntityParticle(directory); + public ScriptParticle createParticle(String directory){ + return new ScriptParticle(directory); + } + + public ScriptParticle createEntityParticle(String directory){ + return new ScriptParticle(directory); } public int getServerTime() { From a825d885f5d7380d2c94534e42bafd22a884ba97 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Fri, 6 May 2022 03:43:53 -0500 Subject: [PATCH 21/75] Removed "move" variable from CustomFX. --- src/main/java/noppes/npcs/client/fx/CustomFX.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/noppes/npcs/client/fx/CustomFX.java b/src/main/java/noppes/npcs/client/fx/CustomFX.java index ad7292759..7ed8dc0d0 100644 --- a/src/main/java/noppes/npcs/client/fx/CustomFX.java +++ b/src/main/java/noppes/npcs/client/fx/CustomFX.java @@ -24,10 +24,9 @@ import java.io.IOException; import java.io.InputStream; public class CustomFX extends EntityFX { - private Entity entity = null; + private final Entity entity; private final ResourceLocation location; private static final ResourceLocation resource = new ResourceLocation("textures/particle/particles.png"); - private boolean move = true; private float startX = 0, startY = 0, startZ = 0; public float scale1 = 1.0F; @@ -209,7 +208,7 @@ public class CustomFX extends EntityFX { getURLWidthHeight(); } - if(move && entity != null){ + if(entity != null){ startX = (float)(entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTick); startY = (float)(entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTick); startZ = (float)(entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTick); From d49a31a4fe941ca814e44b1c129bbca694279f9f Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Sat, 7 May 2022 01:40:41 -0500 Subject: [PATCH 22/75] ScriptParticle: -The spawnInWorld() function now requires a ScriptWorld object to be passed in as the first parameter. -New spawnInWorld() function with its only parameter being a ScriptWorld object. Spawns in the world with the particle's x,y,z variables. --- .../java/noppes/npcs/NoppesUtilServer.java | 4 ++-- .../java/noppes/npcs/client/NoppesUtil.java | 7 ++++++- .../noppes/npcs/scripted/ScriptParticle.java | 21 ++++++++++++++++--- .../noppes/npcs/scripted/ScriptWorld.java | 18 +++++++++++++--- .../npcs/scripted/entity/ScriptEntity.java | 12 +++++------ 5 files changed, 47 insertions(+), 15 deletions(-) diff --git a/src/main/java/noppes/npcs/NoppesUtilServer.java b/src/main/java/noppes/npcs/NoppesUtilServer.java index ba4c50d5f..7ef7924ce 100644 --- a/src/main/java/noppes/npcs/NoppesUtilServer.java +++ b/src/main/java/noppes/npcs/NoppesUtilServer.java @@ -322,7 +322,7 @@ public class NoppesUtilServer { float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart, boolean facePlayer, int width, int height, int offsetX, int offsetY, int animRate, boolean animLoop, int animStart, int animEnd, - int entityID + int entityID, int dimensionID ){ Server.sendToAll(EnumPacketClient.SCRIPTED_PARTICLE, directory, HEXcolor, amount, maxAge, @@ -335,7 +335,7 @@ public class NoppesUtilServer { rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, facePlayer, width, height, offsetX, offsetY, animRate, animLoop, animStart, animEnd, - entityID + entityID, dimensionID ); } diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index 78636bae7..bf1b90c48 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -19,6 +19,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Util; import net.minecraft.world.World; +import net.minecraftforge.common.DimensionManager; import noppes.npcs.CustomNpcs; import noppes.npcs.NoppesUtilPlayer; import noppes.npcs.Server; @@ -125,9 +126,13 @@ public class NoppesUtil { int animEnd = buffer.readInt(); int entityID = buffer.readInt(); + int dimensionID = buffer.readInt(); + + World worldObj = DimensionManager.getWorld(dimensionID); - World worldObj = Minecraft.getMinecraft().theWorld; Entity entity = worldObj.getEntityByID(entityID); + if(entity != null) + worldObj = entity.worldObj; CustomFX fx = new CustomFX( worldObj, entity, diff --git a/src/main/java/noppes/npcs/scripted/ScriptParticle.java b/src/main/java/noppes/npcs/scripted/ScriptParticle.java index 3ece802b0..5038a20a5 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptParticle.java +++ b/src/main/java/noppes/npcs/scripted/ScriptParticle.java @@ -58,11 +58,11 @@ public class ScriptParticle { rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, facePlayer, width, height, offsetX, offsetY, animRate, animLoop, animStart, animEnd, - entityID + entityID, entity.getWorld().getDimensionID() ); } - public void spawnInWorld(double x, double y, double z){ + public void spawnInWorld(ScriptWorld world){ NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge, x, y, z, motionX, motionY, motionZ, gravity, @@ -73,7 +73,22 @@ public class ScriptParticle { rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, facePlayer, width, height, offsetX, offsetY, animRate, animLoop, animStart, animEnd, - -1 + -1, world.getDimensionID() + ); + } + + public void spawnInWorld(ScriptWorld world, double x, double y, double z){ + NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge, + x, y, z, + motionX, motionY, motionZ, gravity, + scale1, scale2, scaleRate, scaleRateStart, + alpha1, alpha2, alphaRate, alphaRateStart, + rotationX1, rotationX2, rotationXRate, rotationXRateStart, + rotationY1, rotationY2, rotationYRate, rotationYRateStart, + rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, + facePlayer, width, height, offsetX, offsetY, + animRate, animLoop, animStart, animEnd, + -1, world.getDimensionID() ); } diff --git a/src/main/java/noppes/npcs/scripted/ScriptWorld.java b/src/main/java/noppes/npcs/scripted/ScriptWorld.java index aad1a3fd4..306e07e9b 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptWorld.java +++ b/src/main/java/noppes/npcs/scripted/ScriptWorld.java @@ -330,13 +330,25 @@ public class ScriptWorld implements IWorld { } /** - * @param directory The particle's texture directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/tail.png" - * @return Returns ScriptEntityParticle object + * @param directory The particle's texture directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/bubble.png" + * @return Returns ScriptParticle object */ public ScriptParticle createEntityParticle(String directory){ return new ScriptParticle(directory); } - + + public ScriptParticle createParticle(String directory){ + return new ScriptParticle(directory); + } + + public void spawnParticle(ScriptParticle particle){ + particle.spawnInWorld(this); + } + + public void spawnParticle(ScriptParticle particle, double x, double y, double z){ + particle.spawnInWorld(this,x,y,z); + } + /** * @param key Get temp data for this key * @return Returns the stored temp data diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index 819d834f3..fd024f580 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -83,7 +83,7 @@ public class ScriptEntity implements IEntity { rotationZ1, rotationZ2, rotationZRate, rotationZRateStart, true, -1, -1, 0,0, 0, true, 0, 0, - entityID + entityID, entity.dimension ); } public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge, @@ -103,7 +103,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, true, -1, -1, 0,0, 0, true, 0, 0, - entityID + entityID, entity.dimension ); } public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge, @@ -122,7 +122,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, true, -1, -1, 0,0, 0, true, 0, 0, - entityID + entityID, entity.dimension ); } public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge, @@ -140,7 +140,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, true, -1, -1, 0,0, 0, true, 0, 0, - entityID + entityID, entity.dimension ); } public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge, @@ -157,7 +157,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, true, -1, -1, 0,0, 0, true, 0, 0, - entityID + entityID, entity.dimension ); } public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge @@ -173,7 +173,7 @@ public class ScriptEntity implements IEntity { 0, 0, 0, 0, true, -1, -1, 0,0, 0, true, 0, 0, - entityID + entityID, entity.dimension ); } public void spawnParticle(ScriptParticle entityParticle) { entityParticle.spawnOnEntity(this); } From 5520fc5f2be706564b1f004a766a1fefa3772fed Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Sat, 7 May 2022 03:46:37 -0500 Subject: [PATCH 23/75] ScriptParticle: -Added HEXColor2, HEXColorRate, and HEXColorRateStart fields, and respective setters and getters, allowing for changes in HEX color over time. Marked plenty of old ScriptEntityParticle functions as deprecated. This includes any functions referring to scripted particles as "Entity Particles" and functions outside the API or ScriptParticle class used to spawn or create particles. --- .../java/noppes/npcs/NoppesUtilServer.java | 8 ++- .../java/noppes/npcs/client/NoppesUtil.java | 9 ++- .../java/noppes/npcs/client/fx/CustomFX.java | 54 +++++++++++++---- .../noppes/npcs/scripted/ScriptParticle.java | 60 +++++++++++++++---- .../noppes/npcs/scripted/ScriptWorld.java | 13 +--- .../npcs/scripted/entity/ScriptEntity.java | 35 +++++++++-- .../npcs/scripted/wrapper/WrapperNpcAPI.java | 1 + 7 files changed, 138 insertions(+), 42 deletions(-) diff --git a/src/main/java/noppes/npcs/NoppesUtilServer.java b/src/main/java/noppes/npcs/NoppesUtilServer.java index 7ef7924ce..9940ec7b8 100644 --- a/src/main/java/noppes/npcs/NoppesUtilServer.java +++ b/src/main/java/noppes/npcs/NoppesUtilServer.java @@ -312,7 +312,9 @@ public class NoppesUtilServer { Server.sendAssociatedData(entity, EnumPacketClient.PARTICLE, entity.posX, entity.posY, entity.posZ, entity.height, entity.width, entity.yOffset, particle); } - public static void spawnScriptedParticle(String directory, int HEXcolor, int amount, int maxAge, + public static void spawnScriptedParticle(String directory, + int HEXColor, int HEXColor2, float colorRate, int rateStart, + int amount, int maxAge, double x, double y, double z, double motionX, double motionY, double motionZ, float gravity, float scale1, float scale2, float scaleRate, int scaleRateStart, @@ -325,7 +327,9 @@ public class NoppesUtilServer { int entityID, int dimensionID ){ Server.sendToAll(EnumPacketClient.SCRIPTED_PARTICLE, - directory, HEXcolor, amount, maxAge, + directory, + HEXColor, HEXColor2, colorRate, rateStart, + amount, maxAge, x, y, z, motionX, motionY, motionZ, gravity, scale1, scale2, scaleRate, scaleRateStart, diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index bf1b90c48..110ecf88c 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -75,7 +75,11 @@ public class NoppesUtil { String directory = Server.readString(buffer); - int HEXcolor = buffer.readInt(); + int HEXColor = buffer.readInt(); + int HEXColor2 = buffer.readInt(); + float colorRate = buffer.readFloat(); + int colorRateStart = buffer.readInt(); + int amount = buffer.readInt(); int maxAge = buffer.readInt(); @@ -136,7 +140,8 @@ public class NoppesUtil { CustomFX fx = new CustomFX( worldObj, entity, - directory, HEXcolor, + directory, + HEXColor,HEXColor2,colorRate,colorRateStart, x, y, z, motionX, motionY, motionZ, gravity, scale1, scale2, scaleRate, scaleRateStart, diff --git a/src/main/java/noppes/npcs/client/fx/CustomFX.java b/src/main/java/noppes/npcs/client/fx/CustomFX.java index 7ed8dc0d0..941da61a9 100644 --- a/src/main/java/noppes/npcs/client/fx/CustomFX.java +++ b/src/main/java/noppes/npcs/client/fx/CustomFX.java @@ -70,11 +70,18 @@ public class CustomFX extends EntityFX { private int animPosX; private int animPosY; + public int HEXColor = 0xFFFFFF; + public int HEXColor2 = 0xFFFFFF; + public float HEXColorRate = 0.0F; + public int HEXColorStart = 0; + private ImageDownloadAlt imageDownloadAlt = null; private boolean isUrl = false; private boolean gotWidthHeight = false; - public CustomFX(World worldObj, Entity entity, String directory, int HEXColor, double x, double y, double z, + public CustomFX(World worldObj, Entity entity, String directory, + int HEXColor, int HEXColor2, float HEXColorRate, int HEXColorStart, + double x, double y, double z, double motionX, double motionY, double motionZ, float gravity, float scale1, float scale2, float scaleRate, int scaleRateStart, float alpha1, float alpha2, float alphaRate, int alphaRateStart, @@ -86,6 +93,14 @@ public class CustomFX extends EntityFX { ) { super(worldObj, x, y, z, motionX, motionY, motionZ); + this.HEXColor = HEXColor; + this.HEXColor2 = HEXColor2; + this.HEXColorRate = HEXColorRate; + this.HEXColorStart = HEXColorStart; + particleRed = (HEXColor >> 16 & 255) / 255f; + particleGreen = (HEXColor >> 8 & 255) / 255f; + particleBlue = (HEXColor & 255) / 255f; + this.scale1 = scale1; this.scale2 = scale2; this.scaleRate = Math.abs(scaleRate); @@ -136,10 +151,6 @@ public class CustomFX extends EntityFX { this.entity = entity; noClip = true; - particleRed = (HEXColor >> 16 & 255) / 255f; - particleGreen = (HEXColor >> 8 & 255) / 255f; - particleBlue = (HEXColor & 255) / 255f; - location = new ResourceLocation(directory); this.width = width; @@ -196,6 +207,13 @@ public class CustomFX extends EntityFX { } } } + + particleRed = (HEXColor >> 16 & 255) / 255f; + particleGreen = (HEXColor >> 8 & 255) / 255f; + particleBlue = (HEXColor & 255) / 255f; + + if(timeSinceStart >= HEXColorStart) + HEXColor = lerpColor(HEXColor, HEXColor2, HEXColorRate); } @Override @@ -217,31 +235,31 @@ public class CustomFX extends EntityFX { float scaleChange = this.scaleRate / (float)particleMaxAge; if((this.scaleRate < 0 && particleScale+scaleChange < this.scale2) || (this.scaleRate > 0 && particleScale+scaleChange > this.scale2)) particleScale = this.scale2; - else if(particleAge >= this.scaleRateStart) + else if(timeSinceStart >= this.scaleRateStart) particleScale += scaleChange; float alphaChange = this.alphaRate / (float)particleMaxAge; if((this.alphaRate < 0 && particleAlpha+alphaChange < this.alpha2) || (this.alphaRate > 0 && particleAlpha+alphaChange > this.alpha2)) particleAlpha = this.alpha2; - else if(particleAge >= this.alphaRateStart) + else if(timeSinceStart >= this.alphaRateStart) particleAlpha += alphaChange; float rotationXChange = this.rotationXRate / (float)particleMaxAge; if((this.rotationXRate < 0 && rotationX+rotationXChange < this.rotationX2) || (this.rotationXRate > 0 && rotationX+rotationXChange > this.rotationX2)) rotationX = this.rotationX2; - else if(particleAge >= this.rotationXRateStart) + else if(timeSinceStart >= this.rotationXRateStart) rotationX += rotationXChange; float rotationYChange = this.rotationYRate / (float)particleMaxAge; if((this.rotationYRate < 0 && rotationY+rotationYChange < this.rotationY2) || (this.rotationYRate > 0 && rotationY+rotationYChange > this.rotationY2)) rotationY = this.rotationY2; - else if(particleAge >= this.rotationYRateStart) + else if(timeSinceStart >= this.rotationYRateStart) rotationY += rotationYChange; float rotationZChange = this.rotationZRate / (float)particleMaxAge; if((this.rotationZRate < 0 && rotationZ+rotationZChange < this.rotationZ2) || (this.rotationZRate > 0 && rotationZ+rotationZChange > this.rotationZ2)) rotationZ = this.rotationZ2; - else if(particleAge >= this.rotationZRateStart) + else if(timeSinceStart >= this.rotationZRateStart) rotationZ += rotationZChange; renderParticleSide(true, tessellator, partialTick); @@ -325,6 +343,22 @@ public class CustomFX extends EntityFX { this.width = width < 0 ? totalWidth : width; this.height = height < 0 ? totalHeight : height; } + + public int lerpColor(int from, int to, float ratio) { + float ar = (from & 0xFF0000) >> 16; + float ag = (from & 0x00FF00) >> 8; + float ab = (from & 0x0000FF); + + float br = (to & 0xFF0000) >> 16; + float bg = (to & 0x00FF00) >> 8; + float bb = (to & 0x0000FF); + + float rr = ar + ratio * (br - ar); + float rg = ag + ratio * (bg - ag); + float rb = ab + ratio * (bb - ab); + + return (int)(((int)rr << 16) + ((int)rg << 8) + (rb)); + } public int getFXLayer(){ return 0; diff --git a/src/main/java/noppes/npcs/scripted/ScriptParticle.java b/src/main/java/noppes/npcs/scripted/ScriptParticle.java index 5038a20a5..9fc33a4dd 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptParticle.java +++ b/src/main/java/noppes/npcs/scripted/ScriptParticle.java @@ -8,7 +8,12 @@ import noppes.npcs.scripted.entity.ScriptEntity; */ public class ScriptParticle { private String directory; - private int HEXcolor = 0xFFFFFF; + + private int HEXColor = 0xFFFFFF; + private int HEXColor2 = 0xFFFFFF; + private float HEXColorRate = 0.0f; + private int HEXColorStart = 0; + private int amount = 1; private int maxAge = 20; private double x = 0,y = 0,z = 0; @@ -48,7 +53,9 @@ public class ScriptParticle { public void spawnOnEntity(ScriptEntity entity){ int entityID = entity.getMCEntity().getEntityId(); - NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge, + NoppesUtilServer.spawnScriptedParticle(directory, + HEXColor, HEXColor2, HEXColorRate, HEXColorStart, + amount, maxAge, x, y, z, motionX, motionY, motionZ, gravity, scale1, scale2, scaleRate, scaleRateStart, @@ -63,7 +70,9 @@ public class ScriptParticle { } public void spawnInWorld(ScriptWorld world){ - NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge, + NoppesUtilServer.spawnScriptedParticle(directory, + HEXColor, HEXColor2, HEXColorRate, HEXColorStart, + amount, maxAge, x, y, z, motionX, motionY, motionZ, gravity, scale1, scale2, scaleRate, scaleRateStart, @@ -78,7 +87,9 @@ public class ScriptParticle { } public void spawnInWorld(ScriptWorld world, double x, double y, double z){ - NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge, + NoppesUtilServer.spawnScriptedParticle(directory, + HEXColor, HEXColor2, HEXColorRate, HEXColorStart, + amount, maxAge, x, y, z, motionX, motionY, motionZ, gravity, scale1, scale2, scaleRate, scaleRateStart, @@ -128,8 +139,41 @@ public class ScriptParticle { return directory; } - public int getHEXcolor() { - return HEXcolor; + public void setHEXColor(int HEXColor) { + this.HEXColor = HEXColor; + } + public int getHEXColor() { + return HEXColor; + } + public void setHEXColor(int HEXColor, int HEXColor2, float HEXColorRate, int HEXColorStart) { + this.HEXColor = HEXColor; + this.HEXColor2 = HEXColor2; + this.HEXColorRate = HEXColorRate; + this.HEXColorStart = HEXColorStart; + } + public int getHEXColor1() { + return HEXColor; + } + public int getHEXColor2() { + return HEXColor2; + } + public float getHEXColorRate() { + return HEXColorRate; + } + public int getHEXColorStart() { + return HEXColorStart; + } + public void setHEXColor1(int HEXColor) { + this.HEXColor = HEXColor; + } + public void setHEXColor2(int HEXColor2) { + this.HEXColor2 = HEXColor2; + } + public void setHEXColorRate(float HEXColorRate) { + this.HEXColorRate = HEXColorRate; + } + public void setHEXColorStart(int HEXColorStart) { + this.HEXColorStart = HEXColorStart; } public int getAmount() { @@ -208,10 +252,6 @@ public class ScriptParticle { this.directory = directory; } - public void setHEXColor(int HEXcolor) { - this.HEXcolor = HEXcolor; - } - public void setAmount(int amount) { this.amount = amount; } diff --git a/src/main/java/noppes/npcs/scripted/ScriptWorld.java b/src/main/java/noppes/npcs/scripted/ScriptWorld.java index 306e07e9b..166714bf5 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptWorld.java +++ b/src/main/java/noppes/npcs/scripted/ScriptWorld.java @@ -333,22 +333,11 @@ public class ScriptWorld implements IWorld { * @param directory The particle's texture directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/bubble.png" * @return Returns ScriptParticle object */ + @Deprecated public ScriptParticle createEntityParticle(String directory){ return new ScriptParticle(directory); } - public ScriptParticle createParticle(String directory){ - return new ScriptParticle(directory); - } - - public void spawnParticle(ScriptParticle particle){ - particle.spawnInWorld(this); - } - - public void spawnParticle(ScriptParticle particle, double x, double y, double z){ - particle.spawnInWorld(this,x,y,z); - } - /** * @param key Get temp data for this key * @return Returns the stored temp data diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index fd024f580..8e3b0d75c 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -62,6 +62,7 @@ public class ScriptEntity implements IEntity { * @param scaleRate Multiplier for the particle's transparency growth rate * @param alphaRateStart The time at which the particle begins appearing/fading */ + @Deprecated public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge, double x, double y, double z, double motionX, double motionY, double motionZ, float gravity, @@ -73,7 +74,9 @@ public class ScriptEntity implements IEntity { float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart ) { int entityID = entity.getEntityId(); - NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge, + NoppesUtilServer.spawnScriptedParticle(directory, + HEXcolor, HEXcolor, 0, 0, + amount, maxAge, x, y, z, motionX, motionY, motionZ, gravity, scale1, scale2, scaleRate, scaleRateStart, @@ -86,6 +89,8 @@ public class ScriptEntity implements IEntity { entityID, entity.dimension ); } + + @Deprecated public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge, double x, double y, double z, double motionX, double motionY, double motionZ, float gravity, @@ -93,7 +98,9 @@ public class ScriptEntity implements IEntity { float alpha1, float alpha2, float alphaRate, int alphaRateStart ) { int entityID = entity.getEntityId(); - NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge, + NoppesUtilServer.spawnScriptedParticle(directory, + HEXcolor, HEXcolor, 0, 0, + amount, maxAge, x, y, z, motionX, motionY, motionZ, gravity, scale1, scale2, scaleRate, scaleRateStart, @@ -106,13 +113,17 @@ public class ScriptEntity implements IEntity { entityID, entity.dimension ); } + + @Deprecated public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge, double x, double y, double z, double motionX, double motionY, double motionZ, float gravity, float scale1, float scale2, float scaleRate, int scaleRateStart ) { int entityID = entity.getEntityId(); - NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge, + NoppesUtilServer.spawnScriptedParticle(directory, + HEXcolor, HEXcolor, 0, 0, + amount, maxAge, x, y, z, motionX, motionY, motionZ, gravity, scale1, scale2, scaleRate, scaleRateStart, @@ -125,12 +136,16 @@ public class ScriptEntity implements IEntity { entityID, entity.dimension ); } + + @Deprecated public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge, double x, double y, double z, double motionX, double motionY, double motionZ, float gravity ) { int entityID = entity.getEntityId(); - NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge, + NoppesUtilServer.spawnScriptedParticle(directory, + HEXcolor, HEXcolor, 0, 0, + amount, maxAge, x, y, z, motionX, motionY, motionZ, gravity, 0, 0, 0, 0, @@ -143,11 +158,15 @@ public class ScriptEntity implements IEntity { entityID, entity.dimension ); } + + @Deprecated public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge, double x, double y, double z ) { int entityID = entity.getEntityId(); - NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge, + NoppesUtilServer.spawnScriptedParticle(directory, + HEXcolor, HEXcolor, 0, 0, + amount, maxAge, x, y, z, 0, 0, 0, 0, 0, 0, 0, 0, @@ -160,10 +179,14 @@ public class ScriptEntity implements IEntity { entityID, entity.dimension ); } + + @Deprecated public void spawnParticle(String directory, int HEXcolor, int amount, int maxAge ) { int entityID = entity.getEntityId(); - NoppesUtilServer.spawnScriptedParticle(directory, HEXcolor, amount, maxAge, + NoppesUtilServer.spawnScriptedParticle(directory, + HEXcolor, HEXcolor, 0, 0, + amount, maxAge, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java b/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java index 3d2353aea..a994ce2e1 100644 --- a/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java @@ -287,6 +287,7 @@ public class WrapperNpcAPI extends NpcAPI { return new ScriptParticle(directory); } + @Deprecated public ScriptParticle createEntityParticle(String directory){ return new ScriptParticle(directory); } From 26f5f86dca6351d56a92d2e780ebc0b038b0b62d Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 11 May 2022 01:10:31 -0500 Subject: [PATCH 24/75] Implemented Scripted Custom Items. --- src/main/java/noppes/npcs/CustomItems.java | 57 +-- src/main/java/noppes/npcs/EventHooks.java | 49 +- .../java/noppes/npcs/PacketHandlerServer.java | 23 + .../noppes/npcs/ScriptPlayerEventHandler.java | 66 +++ .../java/noppes/npcs/client/ClientProxy.java | 11 +- .../npcs/client/PacketHandlerClient.java | 2 + .../npcs/client/gui/script/GuiScriptItem.java | 28 ++ .../client/renderer/CustomItemRenderer.java | 472 ++++++++++++++++++ .../noppes/npcs/constants/EnumGuiType.java | 53 +- .../npcs/constants/EnumPacketClient.java | 40 +- .../npcs/constants/EnumPacketServer.java | 3 + .../java/noppes/npcs/items/ItemScripted.java | 112 +++++ .../java/noppes/npcs/scripted/NpcAPI.java | 3 +- .../noppes/npcs/scripted/ScriptContainer.java | 1 + .../noppes/npcs/scripted/ScriptWorld.java | 12 +- .../npcs/scripted/entity/ScriptDBCPlayer.java | 9 +- .../npcs/scripted/entity/ScriptEntity.java | 1 + .../scripted/entity/ScriptLivingBase.java | 19 +- .../npcs/scripted/entity/ScriptNpc.java | 36 +- .../npcs/scripted/entity/ScriptPlayer.java | 10 +- .../noppes/npcs/scripted/event/ItemEvent.java | 89 ++++ .../npcs/scripted/event/PlayerEvent.java | 3 +- .../npcs/scripted/interfaces/IContainer.java | 3 +- .../npcs/scripted/interfaces/ICustomItem.java | 25 + .../npcs/scripted/interfaces/ICustomNpc.java | 13 +- .../npcs/scripted/interfaces/IEntity.java | 2 +- .../interfaces/IEntityLivingBase.java | 6 +- .../npcs/scripted/interfaces/IPlayer.java | 4 +- .../npcs/scripted/interfaces/IWorld.java | 3 +- .../npcs/scripted/item/ScriptCustomItem.java | 413 +++++++++++++++ .../scripted/{ => item}/ScriptItemStack.java | 25 +- .../npcs/scripted/roles/ScriptRoleTrader.java | 2 +- .../npcs/scripted/wrapper/WrapperNpcAPI.java | 17 +- .../assets/customnpcs/lang/en_US.lang | 1 + 34 files changed, 1476 insertions(+), 137 deletions(-) create mode 100644 src/main/java/noppes/npcs/client/gui/script/GuiScriptItem.java create mode 100644 src/main/java/noppes/npcs/client/renderer/CustomItemRenderer.java create mode 100644 src/main/java/noppes/npcs/items/ItemScripted.java create mode 100644 src/main/java/noppes/npcs/scripted/event/ItemEvent.java create mode 100644 src/main/java/noppes/npcs/scripted/interfaces/ICustomItem.java create mode 100644 src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java rename src/main/java/noppes/npcs/scripted/{ => item}/ScriptItemStack.java (94%) diff --git a/src/main/java/noppes/npcs/CustomItems.java b/src/main/java/noppes/npcs/CustomItems.java index 425889fca..13613d8a7 100644 --- a/src/main/java/noppes/npcs/CustomItems.java +++ b/src/main/java/noppes/npcs/CustomItems.java @@ -72,55 +72,7 @@ import noppes.npcs.blocks.tiles.TileWallBanner; import noppes.npcs.blocks.tiles.TileWaypoint; import noppes.npcs.blocks.tiles.TileWeaponRack; import noppes.npcs.constants.EnumNpcToolMaterial; -import noppes.npcs.items.ItemBattleAxe; -import noppes.npcs.items.ItemBroadSword; -import noppes.npcs.items.ItemBullet; -import noppes.npcs.items.ItemClaw; -import noppes.npcs.items.ItemCrossbow; -import noppes.npcs.items.ItemDagger; -import noppes.npcs.items.ItemDaggerReversed; -import noppes.npcs.items.ItemElementalStaff; -import noppes.npcs.items.ItemExcalibur; -import noppes.npcs.items.ItemGlaive; -import noppes.npcs.items.ItemGun; -import noppes.npcs.items.ItemGunChainsaw; -import noppes.npcs.items.ItemKunai; -import noppes.npcs.items.ItemKunaiReversed; -import noppes.npcs.items.ItemLeafBlade; -import noppes.npcs.items.ItemMachineGun; -import noppes.npcs.items.ItemMounter; -import noppes.npcs.items.ItemMusic; -import noppes.npcs.items.ItemMusicBanjo; -import noppes.npcs.items.ItemMusicClarinet; -import noppes.npcs.items.ItemMusicOracina; -import noppes.npcs.items.ItemMusicViolin; -import noppes.npcs.items.ItemMusket; -import noppes.npcs.items.ItemNpcArmor; -import noppes.npcs.items.ItemNpcArmorColorable; -import noppes.npcs.items.ItemNpcBlock; -import noppes.npcs.items.ItemNpcCloner; -import noppes.npcs.items.ItemNpcColored; -import noppes.npcs.items.ItemNpcInterface; -import noppes.npcs.items.ItemNpcMovingPath; -import noppes.npcs.items.ItemNpcScripter; -import noppes.npcs.items.ItemNpcWand; -import noppes.npcs.items.ItemNpcWeaponInterface; -import noppes.npcs.items.ItemOrb; -import noppes.npcs.items.ItemPlaceholder; -import noppes.npcs.items.ItemRotatedShield; -import noppes.npcs.items.ItemScythe; -import noppes.npcs.items.ItemShield; -import noppes.npcs.items.ItemSkirt; -import noppes.npcs.items.ItemSlingshot; -import noppes.npcs.items.ItemSoulstoneEmpty; -import noppes.npcs.items.ItemSoulstoneFilled; -import noppes.npcs.items.ItemSpear; -import noppes.npcs.items.ItemStaff; -import noppes.npcs.items.ItemTeleporter; -import noppes.npcs.items.ItemThrowingShuriken; -import noppes.npcs.items.ItemThrowingWeapon; -import noppes.npcs.items.ItemWand; -import noppes.npcs.items.ItemWarhammer; +import noppes.npcs.items.*; import cpw.mods.fml.common.registry.GameRegistry; public class CustomItems { @@ -130,7 +82,8 @@ public class CustomItems { public static Item scripter; public static Item moving; public static Item mount; - public static Item teleporter; + public static Item teleporter; + public static Item scripted_item; public static Item soulstoneEmpty; public static Item soulstoneFull; @@ -300,8 +253,7 @@ public class CustomItems { public static CreativeTabNpcs tabWeapon; public static CreativeTabNpcs tabBlocks = new CreativeTabNpcs("cnpcsb"); public static CreativeTabNpcs tabMisc = new CreativeTabNpcs("cnpcsm"); - - + public static void load(){ GameRegistry.registerTileEntity(TileRedstoneBlock.class, "TileRedstoneBlock"); GameRegistry.registerTileEntity(TileBlockAnvil.class, "TileBlockAnvil"); @@ -338,6 +290,7 @@ public class CustomItems { moving = new ItemNpcMovingPath().setUnlocalizedName("npcMovingPath").setFull3D(); mount = new ItemMounter().setUnlocalizedName("npcMounter").setFull3D(); teleporter = new ItemTeleporter().setUnlocalizedName("npcTeleporter").setFull3D(); + scripted_item = new ItemScripted().setUnlocalizedName("scripted_item").setFull3D(); redstoneBlock = new BlockNpcRedstone().setHardness(50.0F).setResistance(2000).setBlockName("npcRedstoneBlock").setBlockTextureName("customnpcs:npcRedstoneBlock").setCreativeTab(tab); carpentyBench = new BlockCarpentryBench().setBlockName("npcCarpentyBench").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks); diff --git a/src/main/java/noppes/npcs/EventHooks.java b/src/main/java/noppes/npcs/EventHooks.java index abf0a84a8..2d2a42606 100644 --- a/src/main/java/noppes/npcs/EventHooks.java +++ b/src/main/java/noppes/npcs/EventHooks.java @@ -21,11 +21,10 @@ import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.event.world.WorldEvent; import noppes.npcs.controllers.*; import noppes.npcs.controllers.data.ForgeDataScript; -import noppes.npcs.controllers.data.NPCDataScript; import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.*; -import noppes.npcs.scripted.entity.ScriptNpc; +import noppes.npcs.scripted.entity.ScriptEntity; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.event.*; import noppes.npcs.scripted.event.PlayerEvent.ChatEvent; @@ -40,6 +39,8 @@ import noppes.npcs.scripted.interfaces.ICustomGui; import noppes.npcs.scripted.interfaces.IEntity; import noppes.npcs.scripted.interfaces.IItemStack; import noppes.npcs.scripted.interfaces.IWorld; +import noppes.npcs.scripted.item.ScriptCustomItem; +import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.wrapper.WrapperNpcAPI; import noppes.npcs.constants.EnumScriptType; import org.apache.commons.lang3.StringUtils; @@ -50,6 +51,50 @@ public class EventHooks { public EventHooks() { } + public static void onScriptItemInit(ScriptCustomItem handler) { + if (!handler.isClient()) { + noppes.npcs.scripted.event.ItemEvent.InitEvent event = new noppes.npcs.scripted.event.ItemEvent.InitEvent(handler); + handler.callScript(EnumScriptType.INIT, event); + WrapperNpcAPI.EVENT_BUS.post(event); + } + } + + public static void onScriptItemUpdate(ScriptCustomItem handler, EntityPlayer player) { + if (!handler.isClient()) { + noppes.npcs.scripted.event.ItemEvent.UpdateEvent event = new noppes.npcs.scripted.event.ItemEvent.UpdateEvent(handler, (ScriptPlayer)ScriptController.Instance.getScriptForEntity(player)); + handler.callScript(EnumScriptType.TICK, event); + WrapperNpcAPI.EVENT_BUS.post(event); + } + } + + public static boolean onScriptItemTossed(ScriptCustomItem handler, EntityPlayer player, EntityItem entity) { + ItemEvent.TossedEvent event = new ItemEvent.TossedEvent(handler, (ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), (ScriptEntity)NpcAPI.Instance().getIEntity(entity)); + handler.callScript(EnumScriptType.TOSSED, event); + return WrapperNpcAPI.EVENT_BUS.post(event); + } + + public static boolean onScriptItemPickedUp(ScriptCustomItem handler, EntityPlayer player) { + ItemEvent.PickedUpEvent event = new ItemEvent.PickedUpEvent(handler, (ScriptPlayer)ScriptController.Instance.getScriptForEntity(player)); + handler.callScript(EnumScriptType.PICKEDUP, event); + return WrapperNpcAPI.EVENT_BUS.post(event); + } + + public static boolean onScriptItemSpawn(ScriptCustomItem handler, EntityItem entity) { + ItemEvent.SpawnEvent event = new ItemEvent.SpawnEvent(handler, (ScriptEntity)NpcAPI.Instance().getIEntity(entity)); + handler.callScript(EnumScriptType.SPAWN, event); + return WrapperNpcAPI.EVENT_BUS.post(event); + } + + public static boolean onScriptItemInteract(ScriptCustomItem handler, noppes.npcs.scripted.event.ItemEvent.InteractEvent event) { + handler.callScript(EnumScriptType.INTERACT, event); + return WrapperNpcAPI.EVENT_BUS.post(event); + } + + public static boolean onScriptItemAttack(ScriptCustomItem handler, noppes.npcs.scripted.event.ItemEvent.AttackEvent event) { + handler.callScript(EnumScriptType.ATTACK, event); + return WrapperNpcAPI.EVENT_BUS.post(event); + } + public static void onNPCInit(EntityNPCInterface npc) { if(npc == null || npc.wrappedNPC == null) return; diff --git a/src/main/java/noppes/npcs/PacketHandlerServer.java b/src/main/java/noppes/npcs/PacketHandlerServer.java index 8bc44438a..83d839a87 100644 --- a/src/main/java/noppes/npcs/PacketHandlerServer.java +++ b/src/main/java/noppes/npcs/PacketHandlerServer.java @@ -54,6 +54,7 @@ import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.gui.ScriptGui; +import noppes.npcs.scripted.item.ScriptCustomItem; public class PacketHandlerServer{ @@ -123,6 +124,8 @@ public class PacketHandlerServer{ npcScriptPackets(type, buffer, player); else if (type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave) forgeScriptPackets(type, buffer, player); + else if (type == EnumPacketServer.ScriptItemDataGet || type == EnumPacketServer.ScriptItemDataSave) + itemScriptPackets(type, buffer, player); else if (item.getItem() == CustomItems.scripter) scriptPackets(type, buffer, player, npc); else if (item.getItem() == Item.getItemFromBlock(CustomItems.waypoint) || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock)) @@ -187,6 +190,26 @@ public class PacketHandlerServer{ } } + private void itemScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception { + if (type == EnumPacketServer.ScriptItemDataGet) { + ScriptCustomItem iw = new ScriptCustomItem(player.getHeldItem()); + NBTTagCompound compound = iw.getMCNbt(); + compound.setTag("Languages", ScriptController.Instance.nbtLanguages()); + Server.sendData(player, EnumPacketClient.GUI_DATA, new Object[]{compound}); + } else if (type == EnumPacketServer.ScriptItemDataSave) { + if (!player.capabilities.isCreativeMode) { + return; + } + + NBTTagCompound compound = Server.readNBT(buffer); + ScriptCustomItem wrapper = new ScriptCustomItem(player.getHeldItem()); + wrapper.setMCNbt(compound); + wrapper.lastInited = -1L; + wrapper.saveScriptData(); + player.sendContainerToPlayer(player.inventoryContainer); + } + } + private void featherPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException { if(type == EnumPacketServer.DimensionsGet){ HashMap map = new HashMap(); diff --git a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java index 18307e3fd..f0ca3b77c 100644 --- a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java @@ -27,8 +27,11 @@ import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.network.FMLNetworkEvent; import cpw.mods.fml.relauncher.Side; import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.ContainerPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; @@ -36,6 +39,7 @@ import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.event.entity.EntityEvent.EntityConstructing; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.EntityStruckByLightningEvent; import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; import net.minecraftforge.event.entity.item.ItemTossEvent; @@ -46,13 +50,17 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.player.*; import net.minecraftforge.event.world.*; import net.minecraftforge.event.world.WorldEvent.PotentialSpawns; +import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumQuestType; import noppes.npcs.controllers.*; import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.items.ItemScripted; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.event.ForgeEvent; +import noppes.npcs.scripted.item.ScriptCustomItem; +import noppes.npcs.scripted.wrapper.WrapperNpcAPI; import org.lwjgl.input.Mouse; public class ScriptPlayerEventHandler { @@ -70,6 +78,17 @@ public class ScriptPlayerEventHandler { PlayerDataScript handler = ScriptController.Instance.playerScripts; ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(player); EventHooks.onPlayerTick(handler, scriptPlayer); + + for(int i = 0; i < player.inventory.getSizeInventory(); ++i) { + ItemStack item = player.inventory.getStackInSlot(i); + + try { + if (item.stackSize > 0 && item.getItem() == CustomItems.scripted_item) { + ScriptCustomItem isw = (ScriptCustomItem) WrapperNpcAPI.Instance().getIItemStack(item); + EventHooks.onScriptItemUpdate(isw, player); + } + } catch(Exception e) {} + } } PlayerData playerData = PlayerDataController.instance.getPlayerData(player); @@ -96,6 +115,14 @@ public class ScriptPlayerEventHandler { ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); noppes.npcs.scripted.event.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.PlayerEvent.InteractEvent(scriptPlayer, 1, NpcAPI.Instance().getIEntity(event.target)); event.setCanceled(EventHooks.onPlayerInteract(handler, ev)); + + try { + if (event.entityPlayer.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) { + ScriptCustomItem isw = ItemScripted.GetWrapper(event.entityPlayer.getHeldItem()); + noppes.npcs.scripted.event.ItemEvent.InteractEvent eve = new noppes.npcs.scripted.event.ItemEvent.InteractEvent(isw, handler.getPlayer(), 2, NpcAPI.Instance().getIBlock(event.entityPlayer.worldObj, new BlockPos(event.entityPlayer.posX, event.entityPlayer.posY, event.entityPlayer.posZ))); + event.setCanceled(EventHooks.onScriptItemInteract(isw, eve)); + } + } catch(Exception e) {} } } @@ -229,6 +256,13 @@ public class ScriptPlayerEventHandler { PlayerDataScript handler = ScriptController.Instance.playerScripts; ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player); EventHooks.onPlayerPickUp(handler, scriptPlayer, event.pickedUp); + + try { + if (event.player.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) { + ScriptCustomItem isw = ItemScripted.GetWrapper(event.player.getHeldItem()); + EventHooks.onScriptItemPickedUp(isw, event.player); + } + } catch(Exception e) {} } } @@ -325,6 +359,13 @@ public class ScriptPlayerEventHandler { PlayerDataScript handler = ScriptController.Instance.playerScripts; ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player); EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem); + + try { + if (event.player.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) { + ScriptCustomItem isw = ItemScripted.GetWrapper(event.player.getHeldItem()); + EventHooks.onScriptItemTossed(isw, event.player, event.entityItem); + } + } catch (Exception e){}; } } @@ -423,6 +464,17 @@ public class ScriptPlayerEventHandler { noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, event.ammount, event.source); event.setCanceled(EventHooks.onPlayerDamagedEntity(handler, pevent1)); event.ammount = pevent1.damage; + + try { + if (((EntityPlayer) event.source.getEntity()).getHeldItem().getItem() != null + && ((EntityPlayer) event.source.getEntity()).getHeldItem().getItem() == CustomItems.scripted_item + && !event.isCanceled()) { + ScriptCustomItem isw = ItemScripted.GetWrapper(((EntityPlayer) event.source.getEntity()).getHeldItem()); + noppes.npcs.scripted.event.ItemEvent.AttackEvent eve = new noppes.npcs.scripted.event.ItemEvent.AttackEvent(isw, handler.getPlayer(), 1, event.entityLiving); + eve.setCanceled(event.isCanceled()); + event.setCanceled(EventHooks.onScriptItemAttack(isw, eve)); + } + } catch(Exception e) {} } } @@ -464,6 +516,20 @@ public class ScriptPlayerEventHandler { } } + @SubscribeEvent + public void invoke(EntityJoinWorldEvent event) { + if (!event.world.isRemote && event.entity instanceof EntityItem) { + EntityItem entity = (EntityItem)event.entity; + ItemStack stack = entity.getEntityItem(); + + try { + if (stack.stackSize > 0 && stack.getItem() == CustomItems.scripted_item && EventHooks.onScriptItemSpawn(ItemScripted.GetWrapper(stack), entity)) { + event.setCanceled(true); + } + } catch(Exception e) {} + } + } + @SubscribeEvent( priority = EventPriority.HIGHEST ) diff --git a/src/main/java/noppes/npcs/client/ClientProxy.java b/src/main/java/noppes/npcs/client/ClientProxy.java index 7a8434de3..e0b6b07b9 100644 --- a/src/main/java/noppes/npcs/client/ClientProxy.java +++ b/src/main/java/noppes/npcs/client/ClientProxy.java @@ -100,6 +100,7 @@ import noppes.npcs.client.gui.roles.GuiNpcItemGiver; import noppes.npcs.client.gui.roles.GuiNpcTraderSetup; import noppes.npcs.client.gui.roles.GuiNpcTransporter; import noppes.npcs.client.gui.script.GuiScriptGlobal; +import noppes.npcs.client.gui.script.GuiScriptItem; import noppes.npcs.client.model.*; import noppes.npcs.client.renderer.*; import noppes.npcs.client.renderer.blocks.BlockBannerRenderer; @@ -133,6 +134,7 @@ import noppes.npcs.containers.*; import noppes.npcs.controllers.PlayerData; import noppes.npcs.entity.*; +import noppes.npcs.items.ItemScripted; import noppes.npcs.scripted.interfaces.IWorld; import org.lwjgl.input.Keyboard; @@ -358,6 +360,9 @@ public class ClientProxy extends CommonProxy { else if(gui == EnumGuiType.Script && CustomNpcs.ScriptingEnabled) return new GuiScript(npc); + else if (gui == EnumGuiType.ScriptItem) + return new GuiScriptItem(Minecraft.getMinecraft().thePlayer); + else if(gui == EnumGuiType.PlayerAnvil) return new GuiNpcCarpentryBench((ContainerCarpentryBench) container); @@ -536,7 +541,11 @@ public class ClientProxy extends CommonProxy { @Override public void registerItem(Item item) { - MinecraftForgeClient.registerItemRenderer(item, new NpcItemRenderer()); + if (item instanceof ItemScripted) { + MinecraftForgeClient.registerItemRenderer(item, new CustomItemRenderer()); + } else { + MinecraftForgeClient.registerItemRenderer(item, new NpcItemRenderer()); + } } public static void bindTexture(ResourceLocation location) { diff --git a/src/main/java/noppes/npcs/client/PacketHandlerClient.java b/src/main/java/noppes/npcs/client/PacketHandlerClient.java index d3cfca705..9743a1e12 100644 --- a/src/main/java/noppes/npcs/client/PacketHandlerClient.java +++ b/src/main/java/noppes/npcs/client/PacketHandlerClient.java @@ -43,6 +43,8 @@ import noppes.npcs.entity.EntityNPCInterface; import cpw.mods.fml.common.ObfuscationReflectionHelper; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent; +import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.item.ScriptItemStack; public class PacketHandlerClient extends PacketHandlerServer{ diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptItem.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptItem.java new file mode 100644 index 000000000..a6e56cc85 --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptItem.java @@ -0,0 +1,28 @@ +package noppes.npcs.client.gui.script; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.CustomItems; +import noppes.npcs.client.Client; +import noppes.npcs.constants.EnumPacketServer; +import noppes.npcs.scripted.item.ScriptCustomItem; + +public class GuiScriptItem extends GuiScriptInterface { + private ScriptCustomItem item; + + public GuiScriptItem(EntityPlayer player) { + this.handler = this.item = new ScriptCustomItem(new ItemStack(CustomItems.scripted_item)); + Client.sendData(EnumPacketServer.ScriptItemDataGet, new Object[0]); + } + + public void setGuiData(NBTTagCompound compound) { + this.item.setMCNbt(compound); + super.setGuiData(compound); + } + + public void save() { + super.save(); + Client.sendData(EnumPacketServer.ScriptItemDataSave, new Object[]{this.item.getMCNbt()}); + } +} \ No newline at end of file diff --git a/src/main/java/noppes/npcs/client/renderer/CustomItemRenderer.java b/src/main/java/noppes/npcs/client/renderer/CustomItemRenderer.java new file mode 100644 index 000000000..12a4123e6 --- /dev/null +++ b/src/main/java/noppes/npcs/client/renderer/CustomItemRenderer.java @@ -0,0 +1,472 @@ +package noppes.npcs.client.renderer; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.resources.IResource; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.IItemRenderer; +import noppes.npcs.items.ItemRenderInterface; +import noppes.npcs.items.ItemScripted; +import noppes.npcs.scripted.item.ScriptCustomItem; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; +import java.util.Random; + +import static net.minecraft.client.renderer.entity.RenderItem.renderInFrame; + +public class CustomItemRenderer implements IItemRenderer { + private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + private static final ResourceLocation enchant = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + private final Random random = new Random(); + + private int itemRenderTicks = 0; + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return type != ItemRenderType.FIRST_PERSON_MAP; + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return false; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack itemStack, Object... data) { + InputStream inputstream = null; + ScriptCustomItem scriptCustomItem = ItemScripted.GetWrapper(itemStack); + + if(scriptCustomItem.width == -1 || scriptCustomItem.height == -1) { + try { + IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation(scriptCustomItem.texture)); + inputstream = iresource.getInputStream(); + BufferedImage bufferedimage = ImageIO.read(inputstream); + scriptCustomItem.width = bufferedimage.getWidth(); + scriptCustomItem.height = bufferedimage.getHeight(); + scriptCustomItem.saveItemData(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (inputstream != null) { + inputstream.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + if(scriptCustomItem.width == -1 || scriptCustomItem.height == -1) + return; + + if (type == ItemRenderType.INVENTORY) { + renderInventoryCustomItem(scriptCustomItem); + return; + } + + ((ItemScripted) itemStack.getItem()).renderCustomAttributes(itemStack); + + if (type == ItemRenderType.ENTITY) { + EntityItem entityItem = (EntityItem) data[1]; + renderEntityCustomItem(scriptCustomItem, itemStack, entityItem); + return; + } + + EntityLivingBase entityLivingBase = (EntityLivingBase) data[1]; + renderItem3d(scriptCustomItem, entityLivingBase, itemStack); + } + + public void renderEntityCustomItem(ScriptCustomItem scriptCustomItem, ItemStack itemStack, EntityItem entityItem) { + this.itemRenderTicks++; + int pass = 0; + float bobbingY = (float)(Math.sin((float)this.itemRenderTicks/40.0F) + 1) * scriptCustomItem.scaleY/6.0F; + + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, bobbingY, 0.0F); + GL11.glDisable(GL11.GL_LIGHTING); //Forge: Make sure that render states are reset, a renderEffect can derp them up. + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + + ResourceLocation location = new ResourceLocation(scriptCustomItem.texture); + Minecraft.getMinecraft().getTextureManager().bindTexture(location); + + Tessellator tessellator = Tessellator.instance; + + float f14 = 0.0F; + float f15 = 1.0F; + float f4 = 0.0F; + float f5 = 1.0F; + float f6 = 1.0F; + float f7 = 0.5F; + float f8 = 0.25F; + float f10; + + if (RenderManager.instance.options.fancyGraphics) + { + GL11.glPushMatrix(); + + if (renderInFrame) + { + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + } + else + { + GL11.glRotatef((((float)entityItem.age) / 20.0F + entityItem.hoverStart) * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + } + + float f9 = 0.0625F; + f10 = 0.021875F; + int j = itemStack.stackSize; + byte b0; + + if (j < 2) + { + b0 = 1; + } + else if (j < 16) + { + b0 = 2; + } + else if (j < 32) + { + b0 = 3; + } + else + { + b0 = 4; + } + + GL11.glTranslatef(-f7, -f8, -((f9 + f10) * (float)b0 / 2.0F)); + + for (int k = 0; k < b0; ++k) + { + // Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug... + GL11.glTranslatef(0f, 0f, f9 + f10); + + ItemRenderer.renderItemIn2D(tessellator, f15, f4, f14, f5, scriptCustomItem.width, scriptCustomItem.height, f9); + + if (itemStack.hasEffect(pass)) + { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + RenderManager.instance.renderEngine.bindTexture(RES_ITEM_GLINT); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + float f11 = 0.76F; + GL11.glColor4f(0.5F * f11, 0.25F * f11, 0.8F * f11, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + float f12 = 0.125F; + GL11.glScalef(f12, f12, f12); + float f13 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + GL11.glTranslatef(f13, 0.0F, 0.0F); + GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f9); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f12, f12, f12); + f13 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + GL11.glTranslatef(-f13, 0.0F, 0.0F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f9); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + } + + GL11.glPopMatrix(); + } + else + { + int j = itemStack.stackSize; + int b0; + + if (j < 2) + { + b0 = 1; + } + else if (j < 16) + { + b0 = 2; + } + else if (j < 32) + { + b0 = 3; + } + else + { + b0 = 4; + } + + for (int l = 0; l < b0; ++l) + { + GL11.glPushMatrix(); + + if (l > 0) + { + f10 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + float f16 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + float f17 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + GL11.glTranslatef(f10, f16, f17); + } + + if (!renderInFrame) + { + GL11.glRotatef(180.0F - RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F); + } + + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + tessellator.addVertexWithUV((double)(0.0F - f7), (double)(0.0F - f8), 0.0D, (double)f14, (double)f5); + tessellator.addVertexWithUV((double)(f6 - f7), (double)(0.0F - f8), 0.0D, (double)f15, (double)f5); + tessellator.addVertexWithUV((double)(f6 - f7), (double)(1.0F - f8), 0.0D, (double)f15, (double)f4); + tessellator.addVertexWithUV((double)(0.0F - f7), (double)(1.0F - f8), 0.0D, (double)f14, (double)f4); + tessellator.draw(); + GL11.glPopMatrix(); + } + } + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + + public void renderInventoryCustomItem(ScriptCustomItem scriptCustomItem) { + GL11.glPushMatrix(); + int color = scriptCustomItem.getColor(); + float itemRed = (color >> 16 & 255) / 255f; + float itemGreen = (color >> 8 & 255) / 255f; + float itemBlue = (color & 255) / 255f; + GL11.glColor4f(itemRed, itemGreen, itemBlue, 1.0F); + + GL11.glDisable(GL11.GL_LIGHTING); //Forge: Make sure that render states are reset, a renderEffect can derp them up. + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + + ResourceLocation location = new ResourceLocation(scriptCustomItem.texture); + Minecraft.getMinecraft().getTextureManager().bindTexture(location); + renderCustomItemSlot(0,0,16,16, scriptCustomItem.item); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + + if (scriptCustomItem.item.hasEffect(0)) + { + renderEffect(Minecraft.getMinecraft().getTextureManager(), 0, 0); + } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + + public void renderEffect(TextureManager manager, int x, int y) + { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + manager.bindTexture(RES_ITEM_GLINT); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F); + this.renderGlint(x - 2, y - 2, 20, 20); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + + private void renderGlint(int p_77018_2_, int p_77018_3_, int p_77018_4_, int p_77018_5_) + { + for (int j1 = 0; j1 < 2; ++j1) + { + OpenGlHelper.glBlendFunc(772, 1, 0, 0); + float f = 0.00390625F; + float f1 = 0.00390625F; + float f2 = (float)(Minecraft.getSystemTime() % (long)(3000 + j1 * 1873)) / (3000.0F + (float)(j1 * 1873)) * 256.0F; + float f3 = 0.0F; + Tessellator tessellator = Tessellator.instance; + float f4 = 4.0F; + + if (j1 == 1) + { + f4 = -1.0F; + } + + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double)(p_77018_2_ + 0), (double)(p_77018_3_ + p_77018_5_), 0, (double)((f2 + (float)p_77018_5_ * f4) * f), (double)((f3 + (float)p_77018_5_) * f1)); + tessellator.addVertexWithUV((double)(p_77018_2_ + p_77018_4_), (double)(p_77018_3_ + p_77018_5_), 0, (double)((f2 + (float)p_77018_4_ + (float)p_77018_5_ * f4) * f), (double)((f3 + (float)p_77018_5_) * f1)); + tessellator.addVertexWithUV((double)(p_77018_2_ + p_77018_4_), (double)(p_77018_3_ + 0), 0, (double)((f2 + (float)p_77018_4_) * f), (double)((f3 + 0.0F) * f1)); + tessellator.addVertexWithUV((double)(p_77018_2_ + 0), (double)(p_77018_3_ + 0), 0, (double)((f2 + 0.0F) * f), (double)((f3 + 0.0F) * f1)); + tessellator.draw(); + } + } + + public void renderCustomItemSlot(int posX, int posY, int imageWidth, int imageHeight, ItemStack itemStack) { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double)(posX), (double)(posY + imageHeight), 0, 0, 1); + tessellator.addVertexWithUV((double)(posX + imageWidth), (double)(posY + imageHeight), 0, 1, 1); + tessellator.addVertexWithUV((double)(posX + imageWidth), (double)(posY), 0, 1, 0); + tessellator.addVertexWithUV((double)(posX), (double)(posY), 0, 0, 0); + tessellator.draw(); + } + + public void renderItem3d(ScriptCustomItem scriptCustomItem, EntityLivingBase entityLivingBase, ItemStack itemStack) { + Minecraft mc = Minecraft.getMinecraft(); + TextureManager texturemanager = mc.getTextureManager(); + int par3 = 0; + + ResourceLocation location = new ResourceLocation(scriptCustomItem.texture); + texturemanager.bindTexture(location); + + Tessellator tessellator = Tessellator.instance; + IIcon icon = entityLivingBase.getItemIcon(itemStack, par3); + + if (icon == null) { + return; + } + + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + + renderCustomItemIn2D(itemStack, tessellator, 1.0F, 0.0F, 0.0F, 1.0F, 0.0625F); + + if (itemStack.hasEffect(par3)) { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + texturemanager.bindTexture(enchant); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + float f7 = 0.76F; + GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + float f8 = 0.125F; + GL11.glScalef(f8, f8, f8); + float f9 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + GL11.glTranslatef(f9, 0.0F, 0.0F); + GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f8, f8, f8); + f9 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + GL11.glTranslatef(-f9, 0.0F, 0.0F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } + + public static void renderCustomItemIn2D(ItemStack itemStack, Tessellator p_78439_0_, float p_78439_1_, float p_78439_2_, float p_78439_3_, float p_78439_4_, float p_78439_7_) + { + GL11.glEnable(GL11.GL_BLEND); + + int width = ItemScripted.GetWrapper(itemStack).width; + int height = ItemScripted.GetWrapper(itemStack).height; + + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(0.0F, 0.0F, 1.0F); + p_78439_0_.addVertexWithUV(0.0D, 0.0D, 0.0D, (double)p_78439_1_, (double)p_78439_4_); + p_78439_0_.addVertexWithUV(1.0D, 0.0D, 0.0D, (double)p_78439_3_, (double)p_78439_4_); + p_78439_0_.addVertexWithUV(1.0D, 1.0D, 0.0D, (double)p_78439_3_, (double)p_78439_2_); + p_78439_0_.addVertexWithUV(0.0D, 1.0D, 0.0D, (double)p_78439_1_, (double)p_78439_2_); + p_78439_0_.draw(); + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(0.0F, 0.0F, -1.0F); + p_78439_0_.addVertexWithUV(0.0D, 1.0D, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)p_78439_2_); + p_78439_0_.addVertexWithUV(1.0D, 1.0D, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)p_78439_2_); + p_78439_0_.addVertexWithUV(1.0D, 0.0D, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)p_78439_4_); + p_78439_0_.addVertexWithUV(0.0D, 0.0D, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)p_78439_4_); + p_78439_0_.draw(); + float f5 = 0.5F * (p_78439_1_ - p_78439_3_) / (float)width; + float f6 = 0.5F * (p_78439_4_ - p_78439_2_) / (float)height; + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(-1.0F, 0.0F, 0.0F); + int k; + float f7; + float f8; + + for (k = 0; k < width; ++k) + { + f7 = (float)k / (float)width; + f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5; + p_78439_0_.addVertexWithUV((double)f7, 0.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_4_); + p_78439_0_.addVertexWithUV((double)f7, 0.0D, 0.0D, (double)f8, (double)p_78439_4_); + p_78439_0_.addVertexWithUV((double)f7, 1.0D, 0.0D, (double)f8, (double)p_78439_2_); + p_78439_0_.addVertexWithUV((double)f7, 1.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_2_); + } + + p_78439_0_.draw(); + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(1.0F, 0.0F, 0.0F); + float f9; + + for (k = 0; k < width; ++k) + { + f7 = (float)k / (float)width; + f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5; + f9 = f7 + 1.0F / (float)width; + p_78439_0_.addVertexWithUV((double)f9, 1.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_2_); + p_78439_0_.addVertexWithUV((double)f9, 1.0D, 0.0D, (double)f8, (double)p_78439_2_); + p_78439_0_.addVertexWithUV((double)f9, 0.0D, 0.0D, (double)f8, (double)p_78439_4_); + p_78439_0_.addVertexWithUV((double)f9, 0.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_4_); + } + + p_78439_0_.draw(); + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(0.0F, 1.0F, 0.0F); + + for (k = 0; k < height; ++k) + { + f7 = (float)k / (float)height; + f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6; + f9 = f7 + 1.0F / (float)height; + p_78439_0_.addVertexWithUV(0.0D, (double)f9, 0.0D, (double)p_78439_1_, (double)f8); + p_78439_0_.addVertexWithUV(1.0D, (double)f9, 0.0D, (double)p_78439_3_, (double)f8); + p_78439_0_.addVertexWithUV(1.0D, (double)f9, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)f8); + p_78439_0_.addVertexWithUV(0.0D, (double)f9, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)f8); + } + + p_78439_0_.draw(); + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(0.0F, -1.0F, 0.0F); + + for (k = 0; k < height; ++k) + { + f7 = (float)k / (float)height; + f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6; + p_78439_0_.addVertexWithUV(1.0D, (double)f7, 0.0D, (double)p_78439_3_, (double)f8); + p_78439_0_.addVertexWithUV(0.0D, (double)f7, 0.0D, (double)p_78439_1_, (double)f8); + p_78439_0_.addVertexWithUV(0.0D, (double)f7, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)f8); + p_78439_0_.addVertexWithUV(1.0D, (double)f7, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)f8); + } + + p_78439_0_.draw(); + } +} diff --git a/src/main/java/noppes/npcs/constants/EnumGuiType.java b/src/main/java/noppes/npcs/constants/EnumGuiType.java index eb58809b6..c1cf571a7 100644 --- a/src/main/java/noppes/npcs/constants/EnumGuiType.java +++ b/src/main/java/noppes/npcs/constants/EnumGuiType.java @@ -1,5 +1,56 @@ package noppes.npcs.constants; public enum EnumGuiType { - MainMenuDisplay, MainMenuInv, MainMenuStats, ManageFactions, MainMenuAdvanced, MainMenuGlobal, PlayerBankSmall, PlayerFollowerHire, PlayerFollower, SetupItemGiver, SetupTrader, SetupFollower, PlayerTrader, PlayerTransporter, RedstoneBlock, SetupTransporter, ManageTransport, ManageBanks, MobSpawner, SetupBank, ManageDialogs, ManageQuests, PlayerAnvil, QuestReward, ManageRecipes, QuestItem, NpcRemote, ScriptEvent, MoneyBag, MainMenuAI, MovingPath, PlayerBankUnlock, PlayerBankUprade, PlayerBankLarge, MobSpawnerAdd, PlayerMailbox, PlayerMailman, Waypoint, MerchantAdd, MobSpawnerMounter, Crate, NpcDimensions, Border, BigSign, Script, Companion, CompanionInv, CompanionTalent, CompanionTrader, ManageLinked, CustomGui; + MainMenuDisplay, + MainMenuInv, + MainMenuStats, + ManageFactions, + MainMenuAdvanced, + MainMenuGlobal, + PlayerBankSmall, + PlayerFollowerHire, + PlayerFollower, + SetupItemGiver, + SetupTrader, + SetupFollower, + PlayerTrader, + PlayerTransporter, + RedstoneBlock, + SetupTransporter, + ManageTransport, + ManageBanks, + MobSpawner, + SetupBank, + ManageDialogs, + ManageQuests, + PlayerAnvil, + QuestReward, + ManageRecipes, + QuestItem, + NpcRemote, + ScriptEvent, + MoneyBag, + MainMenuAI, + MovingPath, + PlayerBankUnlock, + PlayerBankUprade, + PlayerBankLarge, + MobSpawnerAdd, + PlayerMailbox, + PlayerMailman, + Waypoint, + MerchantAdd, + MobSpawnerMounter, + Crate, + NpcDimensions, + Border, + BigSign, + Script, + Companion, + CompanionInv, + CompanionTalent, + CompanionTrader, + ManageLinked, + CustomGui, + ScriptItem; } diff --git a/src/main/java/noppes/npcs/constants/EnumPacketClient.java b/src/main/java/noppes/npcs/constants/EnumPacketClient.java index 8587226e9..4629cb35a 100644 --- a/src/main/java/noppes/npcs/constants/EnumPacketClient.java +++ b/src/main/java/noppes/npcs/constants/EnumPacketClient.java @@ -1,5 +1,41 @@ -package noppes.npcs.constants; +package +noppes.npcs.constants; public enum EnumPacketClient { - CHAT, MESSAGE, SYNCRECIPES_ADD, SYNCRECIPES_WORKBENCH, DIALOG, QUEST_COMPLETION, EDIT_NPC, PLAY_SOUND, PLAY_MUSIC, UPDATE_NPC, ROLE, GUI, SCRIPTED_PARTICLE, PARTICLE, DELETE_NPC, SCROLL_LIST, SCROLL_DATA, SCROLL_DATA_PART, SCROLL_SELECTED, GUI_REDSTONE, GUI_WAYPOINT, GUI_DATA, GUI_ERROR, GUI_CLOSE, VILLAGER_LIST, CHATBUBBLE, SYNCRECIPES_CARPENTRYBENCH, CLONE, OPEN_BOOK, DIALOG_DUMMY, CONFIG, ISGUIOPEN, OVERLAY_DATA, OVERLAY_CLOSE, SWING_PLAYER_ARM; + CHAT, + MESSAGE, + SYNCRECIPES_ADD, + SYNCRECIPES_WORKBENCH, + DIALOG, + QUEST_COMPLETION, + EDIT_NPC, + PLAY_SOUND, + PLAY_MUSIC, + UPDATE_NPC, + ROLE, + GUI, + SCRIPTED_PARTICLE, + PARTICLE, + DELETE_NPC, + SCROLL_LIST, + SCROLL_DATA, + SCROLL_DATA_PART, + SCROLL_SELECTED, + GUI_REDSTONE, + GUI_WAYPOINT, + GUI_DATA, + GUI_ERROR, + GUI_CLOSE, + VILLAGER_LIST, + CHATBUBBLE, + SYNCRECIPES_CARPENTRYBENCH, + CLONE, + OPEN_BOOK, + DIALOG_DUMMY, + CONFIG, + ISGUIOPEN, + OVERLAY_DATA, + OVERLAY_CLOSE, + SWING_PLAYER_ARM, + UPDATE_ITEM } diff --git a/src/main/java/noppes/npcs/constants/EnumPacketServer.java b/src/main/java/noppes/npcs/constants/EnumPacketServer.java index 2c5f3f0c3..415f94855 100644 --- a/src/main/java/noppes/npcs/constants/EnumPacketServer.java +++ b/src/main/java/noppes/npcs/constants/EnumPacketServer.java @@ -43,6 +43,9 @@ public enum EnumPacketServer { ScriptNPCSave(CustomNpcsPermissions.TOOL_SCRIPTER, false), ScriptNPCGet(false), + ScriptItemDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, false), + ScriptItemDataGet(false), + LinkedGetAll, LinkedRemove(CustomNpcsPermissions.GLOBAL_LINKED), LinkedAdd(CustomNpcsPermissions.GLOBAL_LINKED), ScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), ScriptDataGet(true), PlayerDataRemove(CustomNpcsPermissions.GLOBAL_PLAYERDATA), diff --git a/src/main/java/noppes/npcs/items/ItemScripted.java b/src/main/java/noppes/npcs/items/ItemScripted.java new file mode 100644 index 000000000..aa75ad924 --- /dev/null +++ b/src/main/java/noppes/npcs/items/ItemScripted.java @@ -0,0 +1,112 @@ +package noppes.npcs.items; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import noppes.npcs.CustomItems; +import noppes.npcs.CustomNpcs; +import noppes.npcs.constants.EnumGuiType; +import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.interfaces.IItemStack; +import noppes.npcs.scripted.item.ScriptCustomItem; +import org.lwjgl.opengl.GL11; + +import java.util.HashMap; + +public class ItemScripted extends Item implements ItemRenderInterface { + public ItemScripted() { + maxStackSize = 1; + setCreativeTab(CustomItems.tab); + CustomNpcs.proxy.registerItem(this); + setHasSubtypes(true); + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister){ + this.itemIcon = Items.iron_pickaxe.getIconFromDamage(0); + } + + @Override + public int getColorFromItemStack(ItemStack itemStack, int par2){ + return 0x8B4513; + } + + @Override + public boolean requiresMultipleRenderPasses(){ + return true; + } + + @Override + public Item setUnlocalizedName(String name){ + GameRegistry.registerItem(this, name); + return super.setUnlocalizedName(name); + } + + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer entityPlayer) + { + if(!world.isRemote) + return stack; + + if(entityPlayer.isSneaking()) { + CustomNpcs.proxy.openGui(0, 0, 0, EnumGuiType.ScriptItem, entityPlayer); + } + entityPlayer.setItemInUse(stack, this.getMaxItemUseDuration(stack)); + return stack; + } + + public int getMaxItemUseDuration(ItemStack stack){ + return (new ScriptCustomItem(stack)).getMaxItemUseDuration(); + } + + public static ScriptCustomItem GetWrapper(ItemStack stack) { + return new ScriptCustomItem(stack); + } + + public boolean showDurabilityBar(ItemStack stack) { + IItemStack istack = NpcAPI.Instance().getIItemStack(stack); + return istack instanceof ScriptCustomItem && (new ScriptCustomItem(stack)).durabilityShow; + } + + public double getDurabilityForDisplay(ItemStack stack) { + IItemStack istack = NpcAPI.Instance().getIItemStack(stack); + return istack instanceof ScriptCustomItem ? 1.0D - (new ScriptCustomItem(stack)).durabilityValue : 1.0D; + } + + public int getItemStackLimit(ItemStack stack) { + IItemStack istack = NpcAPI.Instance().getIItemStack(stack); + return istack instanceof ScriptCustomItem ? (new ScriptCustomItem(stack)).getMaxStackSize() : super.getItemStackLimit(stack); + } + + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { + return true; + } + + @Override + public void renderSpecial() {} + + public void renderCustomAttributes(ItemStack itemStack) { + ScriptCustomItem scriptCustomItem = GetWrapper(itemStack); + + GL11.glTranslatef(scriptCustomItem.translateX, scriptCustomItem.translateY, scriptCustomItem.translateZ); + GL11.glRotatef(scriptCustomItem.rotationX, 1, 0, 0); + GL11.glRotatef(scriptCustomItem.rotationY, 0, 1, 0); + GL11.glRotatef(scriptCustomItem.rotationZ, 0, 0, 1); + GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ); + + int color = scriptCustomItem.getColor(); + float itemRed = (color >> 16 & 255) / 255f; + float itemGreen = (color >> 8 & 255) / 255f; + float itemBlue = (color & 255) / 255f; + GL11.glColor4f(itemRed, itemGreen, itemBlue, 1.0F); + } +} diff --git a/src/main/java/noppes/npcs/scripted/NpcAPI.java b/src/main/java/noppes/npcs/scripted/NpcAPI.java index 6c6fdcbbe..db93c27f7 100644 --- a/src/main/java/noppes/npcs/scripted/NpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/NpcAPI.java @@ -20,6 +20,7 @@ import net.minecraft.world.World; import net.minecraft.world.WorldServer; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.interfaces.*; +import noppes.npcs.scripted.item.ScriptItemStack; public abstract class NpcAPI { private static NpcAPI instance = null; @@ -86,7 +87,7 @@ public abstract class NpcAPI { public abstract ScriptPlayer[] getAllServerPlayers(); - public abstract ScriptItemStack createItem(String id, int damage, int size); + public abstract IItemStack createItem(String id, int damage, int size); public abstract ScriptParticle createParticle(String directory); diff --git a/src/main/java/noppes/npcs/scripted/ScriptContainer.java b/src/main/java/noppes/npcs/scripted/ScriptContainer.java index 450b9a38b..d0197fcd2 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptContainer.java +++ b/src/main/java/noppes/npcs/scripted/ScriptContainer.java @@ -15,6 +15,7 @@ import noppes.npcs.containers.ContainerCustomGui; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.interfaces.IContainer; import noppes.npcs.scripted.interfaces.IItemStack; +import noppes.npcs.scripted.item.ScriptItemStack; public class ScriptContainer implements IContainer { private IInventory inventory; diff --git a/src/main/java/noppes/npcs/scripted/ScriptWorld.java b/src/main/java/noppes/npcs/scripted/ScriptWorld.java index 166714bf5..72db94221 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptWorld.java +++ b/src/main/java/noppes/npcs/scripted/ScriptWorld.java @@ -26,10 +26,15 @@ import noppes.npcs.NoppesUtilServer; import noppes.npcs.blocks.tiles.TileBigSign; import noppes.npcs.controllers.ScriptController; import noppes.npcs.controllers.ServerCloneController; +import noppes.npcs.items.ItemScripted; import noppes.npcs.scripted.entity.ScriptEntity; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.interfaces.IBlock; +import noppes.npcs.scripted.interfaces.IItemStack; import noppes.npcs.scripted.interfaces.IWorld; +import noppes.npcs.scripted.item.ScriptCustomItem; +import noppes.npcs.scripted.item.ScriptItemStack; +import noppes.npcs.scripted.wrapper.WrapperNpcAPI; public class ScriptWorld implements IWorld { private static Map tempData = new HashMap(); @@ -322,11 +327,8 @@ public class ScriptWorld implements IWorld { * @param size The number of items in the item * @return Returns the item */ - public ScriptItemStack createItem(String id, int damage, int size){ - Item item = (Item)Item.itemRegistry.getObject(id); - if(item == null) - return null; - return new ScriptItemStack(new ItemStack(item, size, damage)); + public IItemStack createItem(String id, int damage, int size){ + return WrapperNpcAPI.Instance().createItem(id,damage,size); } /** diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java index 7ea50063b..0a61009c2 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java @@ -5,11 +5,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.scripted.CustomNPCsException; -import noppes.npcs.scripted.NpcAPI; -import noppes.npcs.scripted.ScriptItemStack; - -import java.util.ArrayList; -import java.util.Locale; +import noppes.npcs.scripted.interfaces.IItemStack; +import noppes.npcs.scripted.item.ScriptItemStack; public class ScriptDBCPlayer extends ScriptPlayer{ public T player; @@ -430,7 +427,7 @@ public class ScriptDBCPlayer extends ScriptPlayer{ return compound.getCompoundTag("JRMCEP").getString("extracode"); } - public ScriptItemStack[] getInventory(){ + public IItemStack[] getInventory(){ NBTTagCompound compound = new NBTTagCompound(); this.player.writeToNBT(compound); diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index 8e3b0d75c..bad3c2e98 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -28,6 +28,7 @@ import noppes.npcs.scripted.constants.EntityType; import noppes.npcs.scripted.interfaces.IEntity; import noppes.npcs.scripted.interfaces.INbt; import noppes.npcs.scripted.interfaces.IPos; +import noppes.npcs.scripted.item.ScriptItemStack; public class ScriptEntity implements IEntity { protected T entity; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java index 0220ddfc6..eef846d2b 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java @@ -7,12 +7,13 @@ import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; import net.minecraft.util.EntityDamageSource; -import net.minecraft.util.MathHelper; import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.ScriptItemStack; +import noppes.npcs.scripted.interfaces.IItemStack; +import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.constants.EntityType; import noppes.npcs.scripted.interfaces.IEntityLivingBase; import noppes.npcs.scripted.wrapper.ScriptDamageSource; +import noppes.npcs.scripted.wrapper.WrapperNpcAPI; public class ScriptLivingBase extends ScriptEntity implements IEntityLivingBase { protected T entity; @@ -173,11 +174,8 @@ public class ScriptLivingBase extends ScriptEntity extends ScriptEntity extends ScriptLiving imp /** * @return The item held in the right hand */ - public ScriptItemStack getRightItem(){ - ItemStack item = npc.inventory.getWeapon(); - if(item == null || item.getItem() == null) - return null; - return new ScriptItemStack(item); + public IItemStack getRightItem(){ + return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.getWeapon()); } /** @@ -379,11 +378,8 @@ public class ScriptNpc extends ScriptLiving imp /** * @return The item held in the left hand */ - public ScriptItemStack getLefttItem(){ - ItemStack item = npc.getOffHand(); - if(item == null || item.getItem() == null) - return null; - return new ScriptItemStack(item); + public IItemStack getLefttItem(){ + return WrapperNpcAPI.Instance().getIItemStack(npc.getOffHand()); } /** @@ -400,11 +396,8 @@ public class ScriptNpc extends ScriptLiving imp /** * @return Returns the projectile the npc uses */ - public ScriptItemStack getProjectileItem(){ - ItemStack item = npc.inventory.getProjectile(); - if(item == null || item.getItem() == null) - return null; - return new ScriptItemStack(item); + public IItemStack getProjectileItem(){ + return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.getProjectile()); } /** @@ -488,11 +481,8 @@ public class ScriptNpc extends ScriptLiving imp * @return Returns the worn armor in slot */ @Override - public ScriptItemStack getArmor(int slot){ - ItemStack item = npc.inventory.armor.get(slot); - if(item == null) - return null; - return new ScriptItemStack(item); + public IItemStack getArmor(int slot){ + return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.armor.get(slot)); } /** @@ -514,8 +504,8 @@ public class ScriptNpc extends ScriptLiving imp * @param slot The slot from the NPC's drop list to return (0-8) * @return */ - public ScriptItemStack getLootItem(int slot) { - return new ScriptItemStack(npc.inventory.getStackInSlot(slot+7)); + public IItemStack getLootItem(int slot) { + return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.getStackInSlot(slot+7)); } /** diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index 67f77db16..cacb5dfbd 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -1,7 +1,6 @@ package noppes.npcs.scripted.entity; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -20,11 +19,12 @@ import noppes.npcs.controllers.*; import noppes.npcs.entity.EntityDialogNpc; import noppes.npcs.scripted.*; import noppes.npcs.scripted.constants.EntityType; -import noppes.npcs.scripted.event.FactionEvent; import noppes.npcs.scripted.gui.ScriptGui; import noppes.npcs.scripted.handler.data.IQuest; import noppes.npcs.scripted.interfaces.*; +import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.overlay.ScriptOverlay; +import noppes.npcs.scripted.wrapper.WrapperNpcAPI; import noppes.npcs.util.ValueUtil; import java.util.ArrayList; @@ -238,12 +238,12 @@ public class ScriptPlayer extends ScriptLivingBase * @since 1.7.10d * @return Returns a IItemStack array size 36 */ - public ScriptItemStack[] getInventory(){ - ScriptItemStack[] items = new ScriptItemStack[36]; + public IItemStack[] getInventory(){ + IItemStack[] items = new IItemStack[36]; for(int i = 0; i < player.inventory.mainInventory.length; i++){ ItemStack item = player.inventory.mainInventory[i]; if(item != null) - items[i] = new ScriptItemStack(item); + items[i] = WrapperNpcAPI.Instance().getIItemStack(item); } return items; } diff --git a/src/main/java/noppes/npcs/scripted/event/ItemEvent.java b/src/main/java/noppes/npcs/scripted/event/ItemEvent.java new file mode 100644 index 000000000..f4be4626e --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/event/ItemEvent.java @@ -0,0 +1,89 @@ +package noppes.npcs.scripted.event; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import noppes.npcs.scripted.entity.ScriptEntity; +import noppes.npcs.scripted.interfaces.IEntity; +import noppes.npcs.scripted.interfaces.IPlayer; +import noppes.npcs.scripted.item.ScriptCustomItem; + +public class ItemEvent extends CustomNPCsEvent { + public ScriptCustomItem item; + + public ItemEvent(ScriptCustomItem item) { + this.item = item; + } + + public static class InitEvent extends ItemEvent { + public InitEvent(ScriptCustomItem item) { + super(item); + } + } + + public static class UpdateEvent extends ItemEvent { + public IPlayer player; + + public UpdateEvent(ScriptCustomItem item, IPlayer player) { + super(item); + this.player = player; + } + } + + @Cancelable + public static class TossedEvent extends ItemEvent { + public IEntity entity; + public IPlayer player; + + public TossedEvent(ScriptCustomItem item, IPlayer player, IEntity entity) { + super(item); + this.entity = entity; + this.player = player; + } + } + + public static class PickedUpEvent extends ItemEvent { + public IPlayer player; + + public PickedUpEvent(ScriptCustomItem item, IPlayer player) { + super(item); + this.player = player; + } + } + + @Cancelable + public static class SpawnEvent extends ItemEvent { + public IEntity entity; + public SpawnEvent(ScriptCustomItem item, IEntity entity){ + super(item); + this.entity = entity; + } + } + + @Cancelable + public static class InteractEvent extends ItemEvent { + public final int type; + public final Object target; + public IPlayer player; + + public InteractEvent(ScriptCustomItem item, IPlayer player, int type, Object target) { + super(item); + this.type = type; + this.target = target; + this.player = player; + } + } + + @Cancelable + public static class AttackEvent extends ItemEvent { + public final int type;//1: Hit, 2: Whiff //TODO: Implement type 2 + public final Object target; + public IPlayer player; + + public AttackEvent(ScriptCustomItem item, IPlayer player, int type, Object target) { + super(item); + this.type = type; + this.target = target; + this.player = player; + } + } + +} diff --git a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java index 306bd81f1..a2b53fa4b 100644 --- a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java @@ -6,17 +6,16 @@ package noppes.npcs.scripted.event; import cpw.mods.fml.common.eventhandler.Cancelable; -import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityXPOrb; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import noppes.npcs.scripted.*; import noppes.npcs.scripted.entity.ScriptLivingBase; import noppes.npcs.scripted.interfaces.*; +import noppes.npcs.scripted.item.ScriptItemStack; public class PlayerEvent extends CustomNPCsEvent { public final IPlayer player; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java b/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java index cca6af790..e874fe901 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java @@ -5,10 +5,9 @@ package noppes.npcs.scripted.interfaces; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; -import noppes.npcs.scripted.ScriptItemStack; +import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.entity.ScriptPlayer; public interface IContainer { diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ICustomItem.java b/src/main/java/noppes/npcs/scripted/interfaces/ICustomItem.java new file mode 100644 index 000000000..07af3cc20 --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/interfaces/ICustomItem.java @@ -0,0 +1,25 @@ +package noppes.npcs.scripted.interfaces; + +public interface ICustomItem extends IItemStack { + String getTexture(); + + void setTexture(String var2); + + void setMaxStackSize(int var1); + + double getDurabilityValue(); + + void setDurabilityValue(float var1); + + boolean getDurabilityShow(); + + void setDurabilityShow(boolean var1); + + int getDurabilityColor(); + + void setDurabilityColor(int var1); + + int getColor(); + + void setColor(int var1); +} diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java b/src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java index 47f0fa7ab..11f5dd9e6 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java @@ -6,9 +6,8 @@ package noppes.npcs.scripted.interfaces; import net.minecraft.entity.EntityCreature; -import noppes.npcs.constants.EnumNavType; import noppes.npcs.scripted.ScriptFaction; -import noppes.npcs.scripted.ScriptItemStack; +import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.entity.ScriptLivingBase; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.roles.*; @@ -196,7 +195,7 @@ public interface ICustomNpc extends IEntityLiving { /** * @return The item held in the right hand */ - public ScriptItemStack getRightItem(); + public IItemStack getRightItem(); /** * @param item Item to be held in the right hand @@ -206,7 +205,7 @@ public interface ICustomNpc extends IEntityLiving { /** * @return The item held in the left hand */ - public ScriptItemStack getLefttItem(); + public IItemStack getLefttItem(); /** * @param item Item to be held in the left hand @@ -216,7 +215,7 @@ public interface ICustomNpc extends IEntityLiving { /** * @return Returns the projectile the npc uses */ - public ScriptItemStack getProjectileItem(); + public IItemStack getProjectileItem(); /** * @param item Item to be used as projectile @@ -272,7 +271,7 @@ public interface ICustomNpc extends IEntityLiving { * @param slot The armor slot to return. 0:head, 1:body, 2:legs, 3:boots * @return Returns the worn armor in slot */ - public ScriptItemStack getArmor(int slot); + public IItemStack getArmor(int slot); /** * @param slot The armor slot to set. 0:head, 1:body, 2:legs, 3:boots @@ -285,7 +284,7 @@ public interface ICustomNpc extends IEntityLiving { * @param slot The slot from the NPC's drop list to return (0-8) * @return The item in the NPC's drop list slot */ - public ScriptItemStack getLootItem(int slot); + public IItemStack getLootItem(int slot); /** * diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java b/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java index 895e6b242..59e3e19af 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java @@ -7,7 +7,7 @@ package noppes.npcs.scripted.interfaces; import net.minecraft.entity.Entity; import noppes.npcs.scripted.entity.ScriptEntity; -import noppes.npcs.scripted.ScriptItemStack; +import noppes.npcs.scripted.item.ScriptItemStack; public interface IEntity { public double getYOffset(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IEntityLivingBase.java b/src/main/java/noppes/npcs/scripted/interfaces/IEntityLivingBase.java index 846a7ed8b..3bc28a79b 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IEntityLivingBase.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IEntityLivingBase.java @@ -2,7 +2,7 @@ package noppes.npcs.scripted.interfaces; import net.minecraft.entity.EntityLivingBase; import noppes.npcs.scripted.entity.ScriptEntity; -import noppes.npcs.scripted.ScriptItemStack; +import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.entity.ScriptLivingBase; public interface IEntityLivingBase extends IEntity { @@ -82,7 +82,7 @@ public interface IEntityLivingBase extends IEntity extends IEntity extends IEntityLivingBase { @@ -90,7 +90,7 @@ public interface IPlayer extends IEntityLivingBase * @since 1.7.10d * @return Returns a IItemStack array size 36 */ - public ScriptItemStack[] getInventory(); + public IItemStack[] getInventory(); /** * @param item The Item type to be removed diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java index e11471d6b..4e8eb2f83 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java @@ -5,6 +5,7 @@ import net.minecraft.world.WorldServer; import noppes.npcs.scripted.*; import noppes.npcs.scripted.entity.ScriptEntity; import noppes.npcs.scripted.entity.ScriptPlayer; +import noppes.npcs.scripted.item.ScriptItemStack; public interface IWorld { /** @@ -166,7 +167,7 @@ public interface IWorld { * @param size The number of items in the item * @return Returns the item */ - public ScriptItemStack createItem(String id, int damage, int size); + public IItemStack createItem(String id, int damage, int size); /** * @param directory The particle's texture directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/tail.png" diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java new file mode 100644 index 000000000..8afbbbbad --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java @@ -0,0 +1,413 @@ +package noppes.npcs.scripted.item; + +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.EventHooks; +import noppes.npcs.NBTTags; +import noppes.npcs.constants.EnumScriptType; +import noppes.npcs.controllers.IScriptHandler; +import noppes.npcs.controllers.ScriptContainer; +import noppes.npcs.controllers.ScriptController; +import noppes.npcs.scripted.CustomNPCsException; +import noppes.npcs.scripted.interfaces.ICustomItem; + +import java.util.*; + +public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IScriptHandler { + public List scripts = new ArrayList(); + public String scriptLanguage = "ECMAScript"; + public boolean enabled = false; + public long lastInited = -1L; + + public boolean durabilityShow = false; + public double durabilityValue = 1.0D; + public int durabilityColor = -1; + public int itemColor = 0x8B4513; + public int stackSize = 64; + public int maxItemUseDuration = 20; + public boolean loaded = false; + + public String texture = "minecraft:textures/items/iron_pickaxe.png"; + public int width = -1, height = -1; + + public float translateX, translateY, translateZ; + public float scaleX = 1.0F, scaleY = 1.0F, scaleZ = 1.0F; + public float rotationX, rotationY, rotationZ; + + public ScriptCustomItem(ItemStack item) { + super(item); + loadScriptData(); + loadItemData(); + } + + public NBTTagCompound getScriptNBT(NBTTagCompound compound) { + compound.setTag("Scripts", NBTTags.NBTScript(this.scripts)); + compound.setString("ScriptLanguage", this.scriptLanguage); + compound.setBoolean("ScriptEnabled", this.enabled); + return compound; + } + + public void setScriptNBT(NBTTagCompound compound) { + if (compound.hasKey("Scripts")) { + this.scripts = NBTTags.GetScript(compound.getTagList("Scripts", 10), this); + this.scriptLanguage = compound.getString("ScriptLanguage"); + this.enabled = compound.getBoolean("ScriptEnabled"); + } + } + + public int getType() { + return 6; + } + + public void callScript(EnumScriptType type, Event event) { + if (!this.loaded) { + this.loadScriptData(); + this.loaded = true; + } + + if (this.isEnabled()) { + if (ScriptController.Instance.lastLoaded > this.lastInited) { + this.lastInited = ScriptController.Instance.lastLoaded; + if (type != EnumScriptType.INIT) { + EventHooks.onScriptItemInit(this); + } + } + + Iterator var3 = this.scripts.iterator(); + + while(var3.hasNext()) { + ScriptContainer script = (ScriptContainer)var3.next(); + script.run(type, event); + } + + } + } + + private boolean isEnabled() { + return this.enabled && ScriptController.HasStart; + } + + public boolean isClient() { + return false; + } + + public boolean getEnabled() { + return this.enabled; + } + + public void setEnabled(boolean bo) { + this.enabled = bo; + } + + public String getLanguage() { + return this.scriptLanguage; + } + + public void setLanguage(String lang) { + this.scriptLanguage = lang; + } + + public List getScripts() { + return this.scripts; + } + + public String noticeString() { + return "ScriptedItem"; + } + + public Map getConsoleText() { + Map map = new TreeMap(); + int tab = 0; + Iterator var3 = this.getScripts().iterator(); + + while(var3.hasNext()) { + ScriptContainer script = (ScriptContainer)var3.next(); + ++tab; + Iterator var5 = script.console.entrySet().iterator(); + + while(var5.hasNext()) { + Map.Entry entry = (Map.Entry)var5.next(); + map.put(entry.getKey(), " tab " + tab + ":\n" + (String)entry.getValue()); + } + } + + return map; + } + + public void clearConsole() { + Iterator var1 = this.getScripts().iterator(); + + while(var1.hasNext()) { + ScriptContainer script = (ScriptContainer)var1.next(); + script.console.clear(); + } + + } + + public String getTexture() { + return this.texture == null ? "" : this.texture; + } + + public void setTexture(String texture){ + if(texture == null) + texture = ""; + this.texture = texture; + saveItemData(); + } + + public int getMaxStackSize() { + return this.stackSize; + } + + public void setMaxStackSize(int size) { + if (size >= 1 && size <= 64) { + this.stackSize = size; + saveItemData(); + } else { + throw new CustomNPCsException("Stacksize has to be between 1 and 64", new Object[0]); + } + } + + public double getDurabilityValue() { + return this.durabilityValue; + } + + public void setDurabilityValue(float value) { + this.durabilityValue = (double)value; + saveItemData(); + } + + public boolean getDurabilityShow() { + return this.durabilityShow; + } + + public void setDurabilityShow(boolean bo) { + this.durabilityShow = bo; + saveItemData(); + } + + public int getDurabilityColor() { + return this.durabilityColor; + } + + public void setDurabilityColor(int color) { + this.durabilityColor = color; + saveItemData(); + } + + public int getColor() { + return this.itemColor; + } + + public void setColor(int color) { + this.itemColor = color; + saveItemData(); + } + + public int getMaxItemUseDuration(){ + return this.maxItemUseDuration; + } + + public void setMaxItemUseDuration(int duration){ + this.maxItemUseDuration = duration; + saveItemData(); + } + + public void setRotation(float rotationX, float rotationY, float rotationZ){ + this.rotationX = rotationX; + this.rotationY = rotationY; + this.rotationZ = rotationZ; + saveItemData(); + } + + public void setScale(float scaleX, float scaleY, float scaleZ){ + this.scaleX = scaleX; + this.scaleY = scaleY; + this.scaleZ = scaleZ; + saveItemData(); + } + + public void setTranslate(float translateX, float translateY, float translateZ){ + this.translateX = translateX; + this.translateY = translateY; + this.translateZ = translateZ; + saveItemData(); + } + + public void setRotationX(float rotationX) { + this.rotationX = rotationX; + saveItemData(); + } + + public void setRotationY(float rotationY) { + this.rotationY = rotationY; + saveItemData(); + } + + public void setRotationZ(float rotationZ) { + this.rotationZ = rotationZ; + saveItemData(); + } + + public void setScaleX(float scaleX) { + this.scaleX = scaleX; + saveItemData(); + } + + public void setScaleY(float scaleY) { + this.scaleY = scaleY; + saveItemData(); + } + + public void setScaleZ(float scaleZ) { + this.scaleZ = scaleZ; + saveItemData(); + } + + public void setTranslateX(float translateX) { + this.translateX = translateX; + saveItemData(); + } + + public void setTranslateY(float translateY) { + this.translateY = translateY; + saveItemData(); + } + + public void setTranslateZ(float translateZ) { + this.translateZ = translateZ; + saveItemData(); + } + + public float getRotationX() { + return rotationX; + } + + public float getRotationY() { + return rotationY; + } + + public float getRotationZ() { + return rotationZ; + } + + public float getScaleX() { + return scaleX; + } + + public float getScaleY() { + return scaleY; + } + + public float getScaleZ() { + return scaleZ; + } + + public float getTranslateX() { + return translateX; + } + + public float getTranslateY() { + return translateY; + } + + public float getTranslateZ() { + return translateZ; + } + + public NBTTagCompound getMCNbt() { + NBTTagCompound compound = super.getMCNbt(); + compound.setTag("ItemData", this.getItemNBT(new NBTTagCompound())); + compound.setTag("ScriptedData", this.getScriptNBT(new NBTTagCompound())); + return compound; + } + + public void setMCNbt(NBTTagCompound compound) { + setScriptNBT(compound.getCompoundTag("ScriptedData")); + setItemNBT(compound.getCompoundTag("ItemData")); + } + + public NBTTagCompound getItemNBT(NBTTagCompound compound) { + compound.setBoolean("DurabilityShow",this.durabilityShow); + compound.setDouble("DurabilityValue",this.durabilityValue); + compound.setInteger("DurabilityColor",this.durabilityColor ); + compound.setInteger("ItemColor",this.itemColor); + compound.setInteger("MaxStackSize",this.stackSize); + compound.setString("ItemTexture",this.texture); + + compound.setFloat("RotationX",this.rotationX); + compound.setFloat("RotationY",this.rotationY); + compound.setFloat("RotationZ",this.rotationZ); + + compound.setFloat("ScaleX",this.scaleX); + compound.setFloat("ScaleY",this.scaleY); + compound.setFloat("ScaleZ",this.scaleZ); + + compound.setFloat("TranslateX",this.translateX); + compound.setFloat("TranslateY",this.translateY); + compound.setFloat("TranslateZ",this.translateZ); + + compound.setInteger("Width", this.width); + compound.setInteger("Height", this.height); + return compound; + } + + public void setItemNBT(NBTTagCompound compound) { + this.durabilityShow = compound.getBoolean("DurabilityShow"); + this.durabilityValue = compound.getDouble("DurabilityValue"); + if (compound.hasKey("DurabilityColor")) { + this.durabilityColor = compound.getInteger("DurabilityColor"); + } + this.itemColor = compound.getInteger("ItemColor"); + this.stackSize = compound.getInteger("MaxStackSize"); + this.texture = compound.getString("ItemTexture"); + + this.rotationX = compound.getFloat("RotationX"); + this.rotationY = compound.getFloat("RotationY"); + this.rotationZ = compound.getFloat("RotationZ"); + + this.scaleX = compound.getFloat("ScaleX"); + this.scaleY = compound.getFloat("ScaleY"); + this.scaleZ = compound.getFloat("ScaleZ"); + + this.translateX = compound.getFloat("TranslateX"); + this.translateY = compound.getFloat("TranslateY"); + this.translateZ = compound.getFloat("TranslateZ"); + + this.width = compound.getInteger("Width"); + this.height = compound.getInteger("Height"); + } + + public void saveScriptData() { + NBTTagCompound c = this.item.getTagCompound(); + if (c == null) { + this.item.setTagCompound(c = new NBTTagCompound()); + } + + c.setTag("ScriptedData", this.getScriptNBT(new NBTTagCompound())); + } + + public void loadScriptData() { + NBTTagCompound c = this.item.getTagCompound(); + if (c != null) { + this.setScriptNBT(c.getCompoundTag("ScriptedData")); + } + } + + public void saveItemData() { + NBTTagCompound c = this.item.getTagCompound(); + if (c == null) { + this.item.setTagCompound(c = new NBTTagCompound()); + } + + c.setTag("ItemData", this.getItemNBT(new NBTTagCompound())); + } + + public void loadItemData() { + NBTTagCompound c = this.item.getTagCompound(); + if (c != null){ + this.setItemNBT(c.getCompoundTag("ItemData")); + } + } +} diff --git a/src/main/java/noppes/npcs/scripted/ScriptItemStack.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java similarity index 94% rename from src/main/java/noppes/npcs/scripted/ScriptItemStack.java rename to src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java index 81fb082a0..8c735e1b5 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptItemStack.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java @@ -1,4 +1,4 @@ -package noppes.npcs.scripted; +package noppes.npcs.scripted.item; import java.util.ArrayList; import java.util.Iterator; @@ -18,12 +18,16 @@ import net.minecraft.nbt.NBTBase.NBTPrimitive; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; +import noppes.npcs.scripted.CustomNPCsException; +import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.ScriptNbt; import noppes.npcs.scripted.interfaces.IItemStack; import noppes.npcs.scripted.interfaces.INbt; public class ScriptItemStack implements IItemStack { public ItemStack item; - + private NBTTagCompound storedData = new NBTTagCompound(); + public ScriptItemStack(ItemStack item){ this.item = item; } @@ -69,7 +73,12 @@ public class ScriptItemStack implements IItemStack { public String getItemName(){ return item.getItem().getItemStackDisplayName(item); } - + + + public int getMaxStackSize() { + return this.item.getMaxStackSize(); + } + /** * @param size The size of the itemstack. A number between 1 and 64 */ @@ -136,7 +145,7 @@ public class ScriptItemStack implements IItemStack { } public INbt removeTags() { - ScriptNbt nbt = (ScriptNbt)NpcAPI.Instance().getINbt(item.stackTagCompound); + ScriptNbt nbt = (ScriptNbt) NpcAPI.Instance().getINbt(item.stackTagCompound); item.stackTagCompound = null; return nbt; } @@ -362,6 +371,14 @@ public class ScriptItemStack implements IItemStack { return NpcAPI.Instance().getINbt(compound); } + public NBTTagCompound getMCNbt() { + NBTTagCompound compound = new NBTTagCompound(); + this.item.writeToNBT(compound); + return compound; + } + + public void setMCNbt(NBTTagCompound compound) {} + /** * No support is given for this method. Dont use if you dont know what you are doing. * @return Minecraft ItemStack diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java index 353afc2fb..2110974ef 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java @@ -2,7 +2,7 @@ package noppes.npcs.scripted.roles; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleTrader; -import noppes.npcs.scripted.ScriptItemStack; +import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.constants.RoleType; import foxz.utils.Market; diff --git a/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java b/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java index a994ce2e1..60b4c4c59 100644 --- a/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java @@ -32,6 +32,7 @@ import net.minecraft.world.WorldServer; import noppes.npcs.CustomNpcs; import noppes.npcs.NoppesUtilServer; import noppes.npcs.controllers.*; +import noppes.npcs.items.ItemScripted; import noppes.npcs.scripted.*; import noppes.npcs.containers.ContainerNpcInterface; import noppes.npcs.entity.EntityCustomNpc; @@ -41,6 +42,8 @@ import noppes.npcs.scripted.entity.*; import noppes.npcs.scripted.gui.ScriptGui; import noppes.npcs.scripted.handler.*; import noppes.npcs.scripted.interfaces.*; +import noppes.npcs.scripted.item.ScriptCustomItem; +import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.overlay.ScriptOverlay; import noppes.npcs.util.JsonException; import noppes.npcs.util.LRUHashMap; @@ -167,8 +170,11 @@ public class WrapperNpcAPI extends NpcAPI { } public IItemStack getIItemStack(ItemStack itemstack) { - return (IItemStack)(itemstack != null && itemstack.stackSize > 0 ? new ScriptItemStack(itemstack) : new ScriptItemStack(new ItemStack(Item.getItemById(0)))); - + if(itemstack.getItem() instanceof ItemScripted){ + return (ICustomItem) (itemstack != null && itemstack.stackSize > 0 ? new ScriptCustomItem(itemstack) : new ScriptCustomItem(new ItemStack(Item.getItemById(0)))); + } else { + return (IItemStack) (itemstack != null && itemstack.stackSize > 0 ? new ScriptItemStack(itemstack) : new ScriptItemStack(new ItemStack(Item.getItemById(0)))); + } } public IWorld getIWorld(WorldServer world) { @@ -258,11 +264,14 @@ public class WrapperNpcAPI extends NpcAPI { return arr; } - public ScriptItemStack createItem(String id, int damage, int size){ + public IItemStack createItem(String id, int damage, int size){ Item item = (Item)Item.itemRegistry.getObject(id); if(item == null) return null; - return new ScriptItemStack(new ItemStack(item, size, damage)); + if(item instanceof ItemScripted) + return new ScriptCustomItem(new ItemStack(item, size, damage)); + else + return new ScriptItemStack(new ItemStack(item, size, damage)); } public void playSoundAtEntity(ScriptEntity entity, String sound, float volume, float pitch){ diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index 14502512f..534e4ba54 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -520,6 +520,7 @@ item.npcMovingPath.name=Npc Pather item.npcMounter.name=Mounter item.npcTeleporter.name=Teleporter item.npcScripter.name=Scripter +item.scripted_item.name=Scripted Item item.npcBanjo.name=Banjo item.npcViolin.name=Violin From a18cf5625b102e3050e89796ae98e5b8e360c746 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 11 May 2022 02:07:06 -0500 Subject: [PATCH 25/75] Added some more functions for scripted items --- .../java/noppes/npcs/items/ItemScripted.java | 33 ++++++++++-- .../npcs/scripted/item/ScriptCustomItem.java | 53 ++++++++++++++++++- 2 files changed, 81 insertions(+), 5 deletions(-) diff --git a/src/main/java/noppes/npcs/items/ItemScripted.java b/src/main/java/noppes/npcs/items/ItemScripted.java index aa75ad924..8b904612d 100644 --- a/src/main/java/noppes/npcs/items/ItemScripted.java +++ b/src/main/java/noppes/npcs/items/ItemScripted.java @@ -3,6 +3,7 @@ package noppes.npcs.items; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -10,8 +11,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import noppes.npcs.CustomItems; import noppes.npcs.CustomNpcs; @@ -21,8 +20,6 @@ import noppes.npcs.scripted.interfaces.IItemStack; import noppes.npcs.scripted.item.ScriptCustomItem; import org.lwjgl.opengl.GL11; -import java.util.HashMap; - public class ItemScripted extends Item implements ItemRenderInterface { public ItemScripted() { maxStackSize = 1; @@ -87,6 +84,34 @@ public class ItemScripted extends Item implements ItemRenderInterface { return istack instanceof ScriptCustomItem ? (new ScriptCustomItem(stack)).getMaxStackSize() : super.getItemStackLimit(stack); } + public boolean isItemTool(ItemStack stack) + { + IItemStack istack = NpcAPI.Instance().getIItemStack(stack); + return istack instanceof ScriptCustomItem ? (new ScriptCustomItem(stack)).isTool() : super.isItemTool(stack); + } + + public float getDigSpeed(ItemStack stack, Block block, int metadata) + { + IItemStack istack = NpcAPI.Instance().getIItemStack(stack); + return istack instanceof ScriptCustomItem ? (new ScriptCustomItem(stack)).getDigSpeed() : super.getDigSpeed(stack, block, metadata); + } + + public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) + { + IItemStack istack = NpcAPI.Instance().getIItemStack(stack); + + if((new ScriptCustomItem(stack)).getArmorType() == -1) + return true; + + return istack instanceof ScriptCustomItem ? armorType == (new ScriptCustomItem(stack)).getArmorType() : super.isValidArmor(stack, armorType, entity); + } + + public int getItemEnchantability(ItemStack stack) + { + IItemStack istack = NpcAPI.Instance().getIItemStack(stack); + return istack instanceof ScriptCustomItem ? (new ScriptCustomItem(stack)).getEnchantability() : super.getItemEnchantability(stack); + } + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { return true; } diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java index 8afbbbbad..4046026fb 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java @@ -19,6 +19,7 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS public String scriptLanguage = "ECMAScript"; public boolean enabled = false; public long lastInited = -1L; + public boolean loaded = false; public boolean durabilityShow = false; public double durabilityValue = 1.0D; @@ -26,7 +27,11 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS public int itemColor = 0x8B4513; public int stackSize = 64; public int maxItemUseDuration = 20; - public boolean loaded = false; + + public boolean isTool = false; + public int digSpeed = 1; + public int armorType = -2; //-2: Fits in no armor slot, -1: Fits in all slots, 0 - 4: Fits in Head -> Boots slot respectively + public int enchantability; public String texture = "minecraft:textures/items/iron_pickaxe.png"; public int width = -1, height = -1; @@ -160,6 +165,33 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS return this.stackSize; } + public void setArmorType(int armorType){ + this.armorType = armorType; + saveItemData(); + } + + public int getArmorType(){ + return this.armorType; + } + + public void setIsTool(boolean isTool){ + this.isTool = isTool; + saveItemData(); + } + + public boolean isTool(){ + return this.isTool; + } + + public void setDigSpeed(int digSpeed){ + this.digSpeed = digSpeed; + saveItemData(); + } + + public int getDigSpeed(){ + return this.digSpeed; + } + public void setMaxStackSize(int size) { if (size >= 1 && size <= 64) { this.stackSize = size; @@ -214,6 +246,15 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS saveItemData(); } + public int getEnchantability(){ + return this.enchantability; + } + + public void setEnchantability(int enchantability){ + this.enchantability = enchantability; + saveItemData(); + } + public void setRotation(float rotationX, float rotationY, float rotationZ){ this.rotationX = rotationX; this.rotationY = rotationY; @@ -350,6 +391,11 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS compound.setInteger("Width", this.width); compound.setInteger("Height", this.height); + + compound.setBoolean("IsTool", this.isTool); + compound.setInteger("DigSpeed", this.digSpeed); + compound.setInteger("ArmorType", this.armorType); + compound.setInteger("Enchantability", this.enchantability); return compound; } @@ -377,6 +423,11 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS this.width = compound.getInteger("Width"); this.height = compound.getInteger("Height"); + + this.isTool = compound.getBoolean("IsTool"); + this.digSpeed = compound.getInteger("DigSpeed"); + this.armorType = compound.getInteger("ArmorType"); + this.enchantability = compound.getInteger("Enchantability"); } public void saveScriptData() { From 747730faceec53d312f1535c32497746a2288594 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 11 May 2022 02:33:56 -0500 Subject: [PATCH 26/75] Fixed a bug with item uses, custom items can now do block, bow, eat, and drink animations. --- .../java/noppes/npcs/items/ItemScripted.java | 24 ++++++++++++++++--- .../npcs/scripted/item/ScriptCustomItem.java | 19 ++++++++++++++- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/main/java/noppes/npcs/items/ItemScripted.java b/src/main/java/noppes/npcs/items/ItemScripted.java index 8b904612d..8150dfdb9 100644 --- a/src/main/java/noppes/npcs/items/ItemScripted.java +++ b/src/main/java/noppes/npcs/items/ItemScripted.java @@ -9,6 +9,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; +import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; @@ -51,9 +52,6 @@ public class ItemScripted extends Item implements ItemRenderInterface { public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer entityPlayer) { - if(!world.isRemote) - return stack; - if(entityPlayer.isSneaking()) { CustomNpcs.proxy.openGui(0, 0, 0, EnumGuiType.ScriptItem, entityPlayer); } @@ -116,6 +114,26 @@ public class ItemScripted extends Item implements ItemRenderInterface { return true; } + public EnumAction getItemUseAction(ItemStack stack) + { + IItemStack istack = NpcAPI.Instance().getIItemStack(stack); + if (istack instanceof ScriptCustomItem) { + switch (((ScriptCustomItem) istack).getItemUseAction()) { + case 0: + return EnumAction.none; + case 1: + return EnumAction.block; + case 2: + return EnumAction.bow; + case 3: + return EnumAction.eat; + case 4: + return EnumAction.drink; + } + } + return super.getItemUseAction(stack); + } + @Override public void renderSpecial() {} diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java index 4046026fb..b9320b729 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java @@ -26,7 +26,9 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS public int durabilityColor = -1; public int itemColor = 0x8B4513; public int stackSize = 64; + public int maxItemUseDuration = 20; + public int itemUseAction = 0; //0: none, 1: block, 2: bow, 3: eat, 4: drink public boolean isTool = false; public int digSpeed = 1; @@ -241,11 +243,20 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS return this.maxItemUseDuration; } - public void setMaxItemUseDuration(int duration){ + public void setMaxItemUseDuration(int duration) { this.maxItemUseDuration = duration; saveItemData(); } + public void setItemUseAction(int action) { + this.itemUseAction = action; + saveItemData(); + } + + public int getItemUseAction() { + return this.itemUseAction; + } + public int getEnchantability(){ return this.enchantability; } @@ -396,6 +407,9 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS compound.setInteger("DigSpeed", this.digSpeed); compound.setInteger("ArmorType", this.armorType); compound.setInteger("Enchantability", this.enchantability); + + compound.setInteger("MaxItemUseDuration", this.maxItemUseDuration); + compound.setInteger("ItemUseAction", this.itemUseAction); return compound; } @@ -428,6 +442,9 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS this.digSpeed = compound.getInteger("DigSpeed"); this.armorType = compound.getInteger("ArmorType"); this.enchantability = compound.getInteger("Enchantability"); + + this.maxItemUseDuration = compound.getInteger("MaxItemUseDuration"); + this.itemUseAction = compound.getInteger("ItemUseAction"); } public void saveScriptData() { From 11cc46b48f5c172c965c690cce06c6dd2ff31c6b Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 11 May 2022 13:30:13 -0500 Subject: [PATCH 27/75] Fixed some scripted item events, and fixed positioning of scripted items. --- src/main/java/noppes/npcs/CustomNpcs.java | 4 + src/main/java/noppes/npcs/DataInventory.java | 4 +- src/main/java/noppes/npcs/EventHooks.java | 13 +- .../java/noppes/npcs/PacketHandlerServer.java | 10 +- .../noppes/npcs/ScriptItemEventHandler.java | 112 ++++++++++++++++++ .../noppes/npcs/ScriptPlayerEventHandler.java | 91 +------------- .../client/gui/script/GuiScriptInterface.java | 13 +- .../client/renderer/CustomItemRenderer.java | 21 +++- .../controllers/ServerCloneController.java | 4 +- .../npcs/controllers/data/NPCDataScript.java | 2 +- .../controllers/data/PlayerDataScript.java | 2 +- .../java/noppes/npcs/items/ItemScripted.java | 30 ++++- .../noppes/npcs/scripted/ScriptWorld.java | 15 +-- .../noppes/npcs/scripted/event/ItemEvent.java | 12 +- .../noppes/npcs/scripted/event/NpcEvent.java | 23 ++-- .../npcs/scripted/event/PlayerEvent.java | 7 +- .../scripted/event/ScriptEventDialog.java | 3 +- .../npcs/scripted/interfaces/IWorld.java | 2 +- .../scripted/wrapper/ScriptDamageSource.java | 5 +- .../npcs/scripted/wrapper/WrapperNpcAPI.java | 4 +- 20 files changed, 231 insertions(+), 146 deletions(-) create mode 100644 src/main/java/noppes/npcs/ScriptItemEventHandler.java diff --git a/src/main/java/noppes/npcs/CustomNpcs.java b/src/main/java/noppes/npcs/CustomNpcs.java index 413ca8b3f..a14226b80 100644 --- a/src/main/java/noppes/npcs/CustomNpcs.java +++ b/src/main/java/noppes/npcs/CustomNpcs.java @@ -182,6 +182,10 @@ public class CustomNpcs { MinecraftForge.EVENT_BUS.register(forgeEventHandler); FMLCommonHandler.instance().bus().register(forgeEventHandler); + ScriptItemEventHandler scriptItemEventHandler = new ScriptItemEventHandler(); + MinecraftForge.EVENT_BUS.register(scriptItemEventHandler); + FMLCommonHandler.instance().bus().register(scriptItemEventHandler); + FMLCommonHandler.instance().bus().register(new ServerTickHandler()); registerNpc(EntityNPCHumanMale.class, "npchumanmale"); diff --git a/src/main/java/noppes/npcs/DataInventory.java b/src/main/java/noppes/npcs/DataInventory.java index 601cf1791..924ebd969 100644 --- a/src/main/java/noppes/npcs/DataInventory.java +++ b/src/main/java/noppes/npcs/DataInventory.java @@ -19,8 +19,8 @@ import noppes.npcs.entity.EntityNPCInterface; public class DataInventory implements IInventory{ public HashMap items = new HashMap(); public HashMap dropchance = new HashMap(); - public HashMap weapons = new HashMap(); - public HashMap armor = new HashMap(); + public HashMap weapons = new HashMap(); + public HashMap armor = new HashMap(); public int minExp = 0; public int maxExp = 0; diff --git a/src/main/java/noppes/npcs/EventHooks.java b/src/main/java/noppes/npcs/EventHooks.java index 2d2a42606..49d402c3e 100644 --- a/src/main/java/noppes/npcs/EventHooks.java +++ b/src/main/java/noppes/npcs/EventHooks.java @@ -7,6 +7,7 @@ package noppes.npcs; import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityXPOrb; @@ -53,22 +54,22 @@ public class EventHooks { public static void onScriptItemInit(ScriptCustomItem handler) { if (!handler.isClient()) { - noppes.npcs.scripted.event.ItemEvent.InitEvent event = new noppes.npcs.scripted.event.ItemEvent.InitEvent(handler); + ItemEvent.InitEvent event = new ItemEvent.InitEvent(handler); handler.callScript(EnumScriptType.INIT, event); WrapperNpcAPI.EVENT_BUS.post(event); } } - public static void onScriptItemUpdate(ScriptCustomItem handler, EntityPlayer player) { + public static void onScriptItemUpdate(ScriptCustomItem handler, EntityLivingBase player) { if (!handler.isClient()) { - noppes.npcs.scripted.event.ItemEvent.UpdateEvent event = new noppes.npcs.scripted.event.ItemEvent.UpdateEvent(handler, (ScriptPlayer)ScriptController.Instance.getScriptForEntity(player)); + ItemEvent.UpdateEvent event = new ItemEvent.UpdateEvent(handler, ScriptController.Instance.getScriptForEntity(player)); handler.callScript(EnumScriptType.TICK, event); WrapperNpcAPI.EVENT_BUS.post(event); } } public static boolean onScriptItemTossed(ScriptCustomItem handler, EntityPlayer player, EntityItem entity) { - ItemEvent.TossedEvent event = new ItemEvent.TossedEvent(handler, (ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), (ScriptEntity)NpcAPI.Instance().getIEntity(entity)); + ItemEvent.TossedEvent event = new ItemEvent.TossedEvent(handler, (ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), ScriptController.Instance.getScriptForEntity(entity)); handler.callScript(EnumScriptType.TOSSED, event); return WrapperNpcAPI.EVENT_BUS.post(event); } @@ -80,7 +81,7 @@ public class EventHooks { } public static boolean onScriptItemSpawn(ScriptCustomItem handler, EntityItem entity) { - ItemEvent.SpawnEvent event = new ItemEvent.SpawnEvent(handler, (ScriptEntity)NpcAPI.Instance().getIEntity(entity)); + ItemEvent.SpawnEvent event = new ItemEvent.SpawnEvent(handler, ScriptController.Instance.getScriptForEntity(entity)); handler.callScript(EnumScriptType.SPAWN, event); return WrapperNpcAPI.EVENT_BUS.post(event); } @@ -460,7 +461,7 @@ public class EventHooks { } public static void onForgeEntityEvent(EntityEvent event) { - IEntity e = NpcAPI.Instance().getIEntity(event.entity); + IEntity e = ScriptController.Instance.getScriptForEntity(event.entity); onForgeEvent(new noppes.npcs.scripted.event.ForgeEvent.EntityEvent(event, e), event); } diff --git a/src/main/java/noppes/npcs/PacketHandlerServer.java b/src/main/java/noppes/npcs/PacketHandlerServer.java index 83d839a87..d0bb72d25 100644 --- a/src/main/java/noppes/npcs/PacketHandlerServer.java +++ b/src/main/java/noppes/npcs/PacketHandlerServer.java @@ -79,22 +79,22 @@ public class PacketHandlerServer{ return; } else if (type == EnumPacketServer.CustomGuiButton && player.openContainer instanceof ContainerCustomGui) { ((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer)); - EventHooks.onCustomGuiButton((ScriptPlayer)NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt()); + EventHooks.onCustomGuiButton((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt()); return; } else if (type == EnumPacketServer.CustomGuiSlotChange && player.openContainer instanceof ContainerCustomGui) { ((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer)); - EventHooks.onCustomGuiSlot((ScriptPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt()); + EventHooks.onCustomGuiSlot((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt()); return; } else if(type == EnumPacketServer.CustomGuiUnfocused && player.openContainer instanceof ContainerCustomGui) { ((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer)); - EventHooks.onCustomGuiUnfocused((ScriptPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt()); + EventHooks.onCustomGuiUnfocused((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt()); return; } else if (type == EnumPacketServer.CustomGuiScrollClick && player.openContainer instanceof ContainerCustomGui) { ((ContainerCustomGui) player.openContainer).customGui.fromNBT(Server.readNBT(buffer)); - EventHooks.onCustomGuiScrollClick((ScriptPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt(), buffer.readInt(), CustomGuiController.readScrollSelection(buffer), buffer.readBoolean()); + EventHooks.onCustomGuiScrollClick((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt(), buffer.readInt(), CustomGuiController.readScrollSelection(buffer), buffer.readBoolean()); return; } else if (type == EnumPacketServer.CustomGuiClose) { - EventHooks.onCustomGuiClose((ScriptPlayer)NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer))); + EventHooks.onCustomGuiClose((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer))); return; } diff --git a/src/main/java/noppes/npcs/ScriptItemEventHandler.java b/src/main/java/noppes/npcs/ScriptItemEventHandler.java new file mode 100644 index 000000000..e21ddd8dc --- /dev/null +++ b/src/main/java/noppes/npcs/ScriptItemEventHandler.java @@ -0,0 +1,112 @@ +package noppes.npcs; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.WorldServer; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.event.entity.item.ItemTossEvent; +import net.minecraftforge.event.entity.living.LivingEvent; +import net.minecraftforge.event.entity.living.LivingHurtEvent; +import net.minecraftforge.event.entity.player.EntityInteractEvent; +import noppes.npcs.controllers.ScriptController; +import noppes.npcs.entity.EntityCustomNpc; +import noppes.npcs.items.ItemScripted; +import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.event.ItemEvent; +import noppes.npcs.scripted.interfaces.IItemStack; +import noppes.npcs.scripted.interfaces.IPlayer; +import noppes.npcs.scripted.item.ScriptCustomItem; +import java.util.HashMap; + +public class ScriptItemEventHandler { + public ScriptItemEventHandler() {} + + @SubscribeEvent + public void invoke(LivingEvent.LivingUpdateEvent event) { + if(event.entityLiving == null || event.entityLiving.worldObj == null || event.entityLiving instanceof EntityPlayer) + return; + + if (event.entityLiving instanceof EntityCustomNpc) { + HashMap armor = ((EntityCustomNpc) event.entityLiving).inventory.armor; + HashMap items = ((EntityCustomNpc) event.entityLiving).inventory.items; + HashMap weapons = ((EntityCustomNpc) event.entityLiving).inventory.weapons; + HashMap[] inventories = new HashMap[]{armor, items, weapons}; + + for (HashMap inventory : inventories) { + for (ItemStack stack : inventory.values()) { + if (stack != null && stack.getItem() == CustomItems.scripted_item) { + IItemStack istack = NpcAPI.Instance().getIItemStack(stack); + EventHooks.onScriptItemUpdate((ScriptCustomItem) istack, event.entityLiving); + } + } + } + } else if(event.entityLiving.getHeldItem() != null && event.entityLiving.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) { + IItemStack itemStack = NpcAPI.Instance().getIItemStack(event.entityLiving.getHeldItem()); + EventHooks.onScriptItemUpdate((ScriptCustomItem) itemStack, event.entityLiving); + } + } + + @SubscribeEvent + public void invoke(ItemTossEvent event) { + if(event.player == null || event.player.worldObj == null) + return; + + if(event.player.worldObj instanceof WorldServer) { + try { + if (event.entityItem.getEntityItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) { + ScriptCustomItem isw = ItemScripted.GetWrapper(event.entityItem.getEntityItem()); + EventHooks.onScriptItemTossed(isw, event.player, event.entityItem); + } + } catch (Exception e) {} + } + } + + @SubscribeEvent + public void invoke(PlayerEvent.ItemPickupEvent event) { + if(event.player == null || event.player.worldObj == null) + return; + + if(event.player.worldObj instanceof WorldServer) { + try { + if (event.player.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) { + ScriptCustomItem isw = ItemScripted.GetWrapper(event.player.getHeldItem()); + EventHooks.onScriptItemPickedUp(isw, event.player); + } + } catch(Exception e) {} + } + } + + @SubscribeEvent + public void invoke(EntityJoinWorldEvent event) { + if (!event.world.isRemote && event.entity instanceof EntityItem) { + EntityItem entity = (EntityItem)event.entity; + ItemStack stack = entity.getEntityItem(); + + try { + if (stack.stackSize > 0 && stack.getItem() == CustomItems.scripted_item && EventHooks.onScriptItemSpawn(ItemScripted.GetWrapper(stack), entity)) { + event.setCanceled(true); + } + } catch(Exception e) {} + } + } + + @SubscribeEvent + public void invoke(EntityInteractEvent event) { + if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + return; + + if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { + try { + if (event.entityPlayer.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) { + ScriptCustomItem isw = ItemScripted.GetWrapper(event.entityPlayer.getHeldItem()); + ItemEvent.InteractEvent eve = new ItemEvent.InteractEvent(isw, (IPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer), 2, NpcAPI.Instance().getIBlock(event.entityPlayer.worldObj, new BlockPos(event.entityPlayer.posX, event.entityPlayer.posY, event.entityPlayer.posZ))); + event.setCanceled(EventHooks.onScriptItemInteract(isw, eve)); + } + } catch(Exception e) {} + } + } +} diff --git a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java index f0ca3b77c..d2a49cb65 100644 --- a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java @@ -5,41 +5,18 @@ package noppes.npcs; -import com.google.common.reflect.ClassPath; -import com.google.common.reflect.ClassPath.ClassInfo; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.Vector; - -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.ModContainer; -import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.InputEvent; import cpw.mods.fml.common.gameevent.PlayerEvent; import cpw.mods.fml.common.gameevent.TickEvent; -import cpw.mods.fml.common.network.FMLNetworkEvent; import cpw.mods.fml.relauncher.Side; import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.ContainerPlayer; -import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.EntityEvent; -import net.minecraftforge.event.entity.EntityEvent.EntityConstructing; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.EntityStruckByLightningEvent; import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; import net.minecraftforge.event.entity.item.ItemTossEvent; @@ -49,19 +26,12 @@ import net.minecraftforge.event.entity.living.LivingFallEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.player.*; import net.minecraftforge.event.world.*; -import net.minecraftforge.event.world.WorldEvent.PotentialSpawns; -import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumQuestType; import noppes.npcs.controllers.*; import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.entity.EntityNPCInterface; -import noppes.npcs.items.ItemScripted; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptPlayer; -import noppes.npcs.scripted.event.ForgeEvent; -import noppes.npcs.scripted.item.ScriptCustomItem; -import noppes.npcs.scripted.wrapper.WrapperNpcAPI; -import org.lwjgl.input.Mouse; public class ScriptPlayerEventHandler { public ScriptPlayerEventHandler() { @@ -78,17 +48,6 @@ public class ScriptPlayerEventHandler { PlayerDataScript handler = ScriptController.Instance.playerScripts; ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(player); EventHooks.onPlayerTick(handler, scriptPlayer); - - for(int i = 0; i < player.inventory.getSizeInventory(); ++i) { - ItemStack item = player.inventory.getStackInSlot(i); - - try { - if (item.stackSize > 0 && item.getItem() == CustomItems.scripted_item) { - ScriptCustomItem isw = (ScriptCustomItem) WrapperNpcAPI.Instance().getIItemStack(item); - EventHooks.onScriptItemUpdate(isw, player); - } - } catch(Exception e) {} - } } PlayerData playerData = PlayerDataController.instance.getPlayerData(player); @@ -113,16 +72,8 @@ public class ScriptPlayerEventHandler { if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); - noppes.npcs.scripted.event.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.PlayerEvent.InteractEvent(scriptPlayer, 1, NpcAPI.Instance().getIEntity(event.target)); + noppes.npcs.scripted.event.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.PlayerEvent.InteractEvent(scriptPlayer, 1, ScriptController.Instance.getScriptForEntity(event.target)); event.setCanceled(EventHooks.onPlayerInteract(handler, ev)); - - try { - if (event.entityPlayer.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) { - ScriptCustomItem isw = ItemScripted.GetWrapper(event.entityPlayer.getHeldItem()); - noppes.npcs.scripted.event.ItemEvent.InteractEvent eve = new noppes.npcs.scripted.event.ItemEvent.InteractEvent(isw, handler.getPlayer(), 2, NpcAPI.Instance().getIBlock(event.entityPlayer.worldObj, new BlockPos(event.entityPlayer.posX, event.entityPlayer.posY, event.entityPlayer.posZ))); - event.setCanceled(EventHooks.onScriptItemInteract(isw, eve)); - } - } catch(Exception e) {} } } @@ -256,13 +207,6 @@ public class ScriptPlayerEventHandler { PlayerDataScript handler = ScriptController.Instance.playerScripts; ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player); EventHooks.onPlayerPickUp(handler, scriptPlayer, event.pickedUp); - - try { - if (event.player.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) { - ScriptCustomItem isw = ItemScripted.GetWrapper(event.player.getHeldItem()); - EventHooks.onScriptItemPickedUp(isw, event.player); - } - } catch(Exception e) {} } } @@ -359,13 +303,6 @@ public class ScriptPlayerEventHandler { PlayerDataScript handler = ScriptController.Instance.playerScripts; ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player); EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem); - - try { - if (event.player.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) { - ScriptCustomItem isw = ItemScripted.GetWrapper(event.player.getHeldItem()); - EventHooks.onScriptItemTossed(isw, event.player, event.entityItem); - } - } catch (Exception e){}; } } @@ -464,19 +401,7 @@ public class ScriptPlayerEventHandler { noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, event.ammount, event.source); event.setCanceled(EventHooks.onPlayerDamagedEntity(handler, pevent1)); event.ammount = pevent1.damage; - - try { - if (((EntityPlayer) event.source.getEntity()).getHeldItem().getItem() != null - && ((EntityPlayer) event.source.getEntity()).getHeldItem().getItem() == CustomItems.scripted_item - && !event.isCanceled()) { - ScriptCustomItem isw = ItemScripted.GetWrapper(((EntityPlayer) event.source.getEntity()).getHeldItem()); - noppes.npcs.scripted.event.ItemEvent.AttackEvent eve = new noppes.npcs.scripted.event.ItemEvent.AttackEvent(isw, handler.getPlayer(), 1, event.entityLiving); - eve.setCanceled(event.isCanceled()); - event.setCanceled(EventHooks.onScriptItemAttack(isw, eve)); - } - } catch(Exception e) {} } - } } @@ -516,20 +441,6 @@ public class ScriptPlayerEventHandler { } } - @SubscribeEvent - public void invoke(EntityJoinWorldEvent event) { - if (!event.world.isRemote && event.entity instanceof EntityItem) { - EntityItem entity = (EntityItem)event.entity; - ItemStack stack = entity.getEntityItem(); - - try { - if (stack.stackSize > 0 && stack.getItem() == CustomItems.scripted_item && EventHooks.onScriptItemSpawn(ItemScripted.GetWrapper(stack), entity)) { - event.setCanceled(true); - } - } catch(Exception e) {} - } - } - @SubscribeEvent( priority = EventPriority.HIGHEST ) diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java index 4b0b2928e..7e6100906 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java @@ -20,7 +20,6 @@ import net.minecraft.client.gui.GuiYesNo; import net.minecraft.client.gui.GuiYesNoCallback; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.event.CommandEvent; import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.event.world.ChunkDataEvent; @@ -37,6 +36,7 @@ import noppes.npcs.controllers.ScriptController; import noppes.npcs.controllers.data.ForgeDataScript; import noppes.npcs.controllers.data.NPCDataScript; import noppes.npcs.controllers.data.PlayerDataScript; +import noppes.npcs.scripted.item.ScriptCustomItem; import org.apache.commons.lang3.StringUtils; public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallback, IGuiData, ITextChangeListener, ICustomScrollListener, IJTextAreaListener, ITextfieldListener { @@ -165,6 +165,17 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb hookList.add("dialogClose"); hookList.add("timer"); } + else if(handler instanceof ScriptCustomItem) { + hookList.add("init"); + hookList.add("tick"); + hookList.add("tossed"); + hookList.add("pickedUp"); + hookList.add("spawn"); + hookList.add("interact"); + hookList.add("attack"); + //hookList.add(""); + //hookList.add(""); + } else if(handler instanceof ForgeDataScript) { hooks.setSize(238, 198); hooks.guiLeft = guiLeft - 240; diff --git a/src/main/java/noppes/npcs/client/renderer/CustomItemRenderer.java b/src/main/java/noppes/npcs/client/renderer/CustomItemRenderer.java index 12a4123e6..d875ec1d4 100644 --- a/src/main/java/noppes/npcs/client/renderer/CustomItemRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/CustomItemRenderer.java @@ -79,14 +79,24 @@ public class CustomItemRenderer implements IItemRenderer { return; } - ((ItemScripted) itemStack.getItem()).renderCustomAttributes(itemStack); - if (type == ItemRenderType.ENTITY) { + ((ItemScripted) itemStack.getItem()).renderCustomAttributes(itemStack); EntityItem entityItem = (EntityItem) data[1]; renderEntityCustomItem(scriptCustomItem, itemStack, entityItem); return; } + GL11.glTranslatef(0.9375F, 0.0625F, 0.0F); + GL11.glRotatef(-315.0F, 0.0F, 0.0F, 1.0F); + + ((ItemRenderInterface) itemStack.getItem()).renderSpecial(); + GL11.glTranslatef(scriptCustomItem.translateX, scriptCustomItem.translateY, scriptCustomItem.translateZ); + ((ItemScripted) itemStack.getItem()).renderCustomAttributes(itemStack); + + GL11.glRotatef(-20.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.09375F, 0.0625F, 0.0F); + EntityLivingBase entityLivingBase = (EntityLivingBase) data[1]; renderItem3d(scriptCustomItem, entityLivingBase, itemStack); } @@ -348,6 +358,13 @@ public class CustomItemRenderer implements IItemRenderer { GL11.glEnable(GL12.GL_RESCALE_NORMAL); + float f4 = 0.0F; + float f5 = 0.3F; + GL11.glTranslatef(-f4, -f5, 0.0F); + GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F); + renderCustomItemIn2D(itemStack, tessellator, 1.0F, 0.0F, 0.0F, 1.0F, 0.0625F); if (itemStack.hasEffect(par3)) { diff --git a/src/main/java/noppes/npcs/controllers/ServerCloneController.java b/src/main/java/noppes/npcs/controllers/ServerCloneController.java index 99cc2e437..4dcb0ebcf 100644 --- a/src/main/java/noppes/npcs/controllers/ServerCloneController.java +++ b/src/main/java/noppes/npcs/controllers/ServerCloneController.java @@ -207,7 +207,7 @@ public class ServerCloneController implements ICloneHandler { throw new CustomNPCsException("Unknown clone tab:" + tab + " name:" + name, new Object[0]); } else { Entity entity = NoppesUtilServer.spawnClone(compound, (int)x, (int)y, (int)z, world.getMCWorld()); - return entity == null ? null : NpcAPI.Instance().getIEntity(entity); + return entity == null ? null : ScriptController.Instance.getScriptForEntity(entity); } } @@ -218,7 +218,7 @@ public class ServerCloneController implements ICloneHandler { } else { Instance.cleanTags(compound); Entity entity = EntityList.createEntityFromNBT(compound, world.getMCWorld()); - return entity == null ? null : NpcAPI.Instance().getIEntity(entity); + return entity == null ? null : ScriptController.Instance.getScriptForEntity(entity); } } diff --git a/src/main/java/noppes/npcs/controllers/data/NPCDataScript.java b/src/main/java/noppes/npcs/controllers/data/NPCDataScript.java index 4e05af3e5..44ea2681d 100644 --- a/src/main/java/noppes/npcs/controllers/data/NPCDataScript.java +++ b/src/main/java/noppes/npcs/controllers/data/NPCDataScript.java @@ -120,7 +120,7 @@ public class NPCDataScript implements IScriptHandler { } public ICustomNpc getNpc() { if (this.npcAPI == null) { - this.npcAPI = (ICustomNpc) NpcAPI.Instance().getIEntity(this.npc); + this.npcAPI = (ICustomNpc) ScriptController.Instance.getScriptForEntity(this.npc); } return this.npcAPI; } diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java b/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java index aa9cad05c..ab3e95477 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java @@ -138,7 +138,7 @@ public class PlayerDataScript implements IScriptHandler { } public IPlayer getPlayer() { if (this.playerAPI == null) { - this.playerAPI = (IPlayer) NpcAPI.Instance().getIEntity(this.player); + this.playerAPI = (IPlayer) ScriptController.Instance.getScriptForEntity(this.player); } return this.playerAPI; } diff --git a/src/main/java/noppes/npcs/items/ItemScripted.java b/src/main/java/noppes/npcs/items/ItemScripted.java index 8150dfdb9..43b941229 100644 --- a/src/main/java/noppes/npcs/items/ItemScripted.java +++ b/src/main/java/noppes/npcs/items/ItemScripted.java @@ -4,6 +4,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; +import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -15,9 +16,13 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import noppes.npcs.CustomItems; import noppes.npcs.CustomNpcs; +import noppes.npcs.EventHooks; import noppes.npcs.constants.EnumGuiType; +import noppes.npcs.controllers.ScriptController; import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.event.ItemEvent; import noppes.npcs.scripted.interfaces.IItemStack; +import noppes.npcs.scripted.interfaces.IPlayer; import noppes.npcs.scripted.item.ScriptCustomItem; import org.lwjgl.opengl.GL11; @@ -29,6 +34,12 @@ public class ItemScripted extends Item implements ItemRenderInterface { setHasSubtypes(true); } + @Override + public void onUpdate(ItemStack stack, World world, Entity player, int p_77663_4_, boolean p_77663_5_) { + IItemStack istack = NpcAPI.Instance().getIItemStack(stack); + EventHooks.onScriptItemUpdate((ScriptCustomItem) istack, (EntityPlayer) player); + } + @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister par1IconRegister){ this.itemIcon = Items.iron_pickaxe.getIconFromDamage(0); @@ -59,6 +70,16 @@ public class ItemScripted extends Item implements ItemRenderInterface { return stack; } + @Override + public boolean onEntitySwing(EntityLivingBase entityLivingBase, ItemStack stack){ + if(entityLivingBase instanceof EntityClientPlayerMP) + return false; + + IItemStack istack = NpcAPI.Instance().getIItemStack(stack); + ItemEvent.AttackEvent eve = new ItemEvent.AttackEvent( (ScriptCustomItem) istack, ScriptController.Instance.getScriptForEntity(entityLivingBase), 2, null); + return EventHooks.onScriptItemAttack((ScriptCustomItem) istack, eve); + } + public int getMaxItemUseDuration(ItemStack stack){ return (new ScriptCustomItem(stack)).getMaxItemUseDuration(); } @@ -111,7 +132,9 @@ public class ItemScripted extends Item implements ItemRenderInterface { } public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { - return true; + IItemStack istack = NpcAPI.Instance().getIItemStack(stack); + ItemEvent.AttackEvent eve = new ItemEvent.AttackEvent( (ScriptCustomItem) istack, ScriptController.Instance.getScriptForEntity(attacker), 1, ScriptController.Instance.getScriptForEntity(target)); + return EventHooks.onScriptItemAttack((ScriptCustomItem) istack, eve); } public EnumAction getItemUseAction(ItemStack stack) @@ -135,12 +158,13 @@ public class ItemScripted extends Item implements ItemRenderInterface { } @Override - public void renderSpecial() {} + public void renderSpecial() { + GL11.glTranslatef(0.135F, 0.2F, 0.07F); + } public void renderCustomAttributes(ItemStack itemStack) { ScriptCustomItem scriptCustomItem = GetWrapper(itemStack); - GL11.glTranslatef(scriptCustomItem.translateX, scriptCustomItem.translateY, scriptCustomItem.translateZ); GL11.glRotatef(scriptCustomItem.rotationX, 1, 0, 0); GL11.glRotatef(scriptCustomItem.rotationY, 0, 1, 0); GL11.glRotatef(scriptCustomItem.rotationZ, 0, 0, 1); diff --git a/src/main/java/noppes/npcs/scripted/ScriptWorld.java b/src/main/java/noppes/npcs/scripted/ScriptWorld.java index 72db94221..a25c9ad21 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptWorld.java +++ b/src/main/java/noppes/npcs/scripted/ScriptWorld.java @@ -30,6 +30,7 @@ import noppes.npcs.items.ItemScripted; import noppes.npcs.scripted.entity.ScriptEntity; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.interfaces.IBlock; +import noppes.npcs.scripted.interfaces.IEntity; import noppes.npcs.scripted.interfaces.IItemStack; import noppes.npcs.scripted.interfaces.IWorld; import noppes.npcs.scripted.item.ScriptCustomItem; @@ -146,8 +147,8 @@ public class ScriptWorld implements IWorld { world.playSoundToNearExcept((EntityPlayerMP) player.getMCEntity(), sound, volume, pitch); } - public ScriptEntity getEntityByID(int id){ - return (ScriptEntity) NpcAPI.Instance().getIEntity(world.getEntityByID(id)); + public IEntity getEntityByID(int id){ + return ScriptController.Instance.getScriptForEntity(world.getEntityByID(id)); } public boolean spawnEntityInWorld(ScriptEntity entity){ @@ -155,19 +156,19 @@ public class ScriptWorld implements IWorld { } public ScriptPlayer getClosestPlayerToEntity(ScriptEntity entity, double range){ - return (ScriptPlayer) NpcAPI.Instance().getIEntity(world.getClosestPlayerToEntity(entity.getMCEntity(), range)); + return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(world.getClosestPlayerToEntity(entity.getMCEntity(), range)); } public ScriptPlayer getClosestPlayer(double x, double y, double z, double range){ - return (ScriptPlayer) NpcAPI.Instance().getIEntity(world.getClosestPlayer(x,y,z, range)); + return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(world.getClosestPlayer(x,y,z, range)); } public ScriptPlayer getClosestVulnerablePlayerToEntity(ScriptEntity entity, double range){ - return (ScriptPlayer) NpcAPI.Instance().getIEntity(world.getClosestVulnerablePlayerToEntity(entity.getMCEntity(), range)); + return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(world.getClosestVulnerablePlayerToEntity(entity.getMCEntity(), range)); } public ScriptPlayer getClosestVulnerablePlayer(double x, double y, double z, double range){ - return (ScriptPlayer) NpcAPI.Instance().getIEntity(world.getClosestVulnerablePlayer(x,y,z, range)); + return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(world.getClosestVulnerablePlayer(x,y,z, range)); } public int countEntities(ScriptEntity entity){ @@ -265,7 +266,7 @@ public class ScriptWorld implements IWorld { } public ScriptPlayer getPlayerByUUID(String uuid){ - return (ScriptPlayer) NpcAPI.Instance().getIEntity(world.func_152378_a(UUID.fromString(uuid))); + return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(world.func_152378_a(UUID.fromString(uuid))); } /** diff --git a/src/main/java/noppes/npcs/scripted/event/ItemEvent.java b/src/main/java/noppes/npcs/scripted/event/ItemEvent.java index f4be4626e..6bbb8c4e3 100644 --- a/src/main/java/noppes/npcs/scripted/event/ItemEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/ItemEvent.java @@ -20,11 +20,11 @@ public class ItemEvent extends CustomNPCsEvent { } public static class UpdateEvent extends ItemEvent { - public IPlayer player; + public IEntity entity; - public UpdateEvent(ScriptCustomItem item, IPlayer player) { + public UpdateEvent(ScriptCustomItem item, IEntity entity) { super(item); - this.player = player; + this.entity = entity; } } @@ -76,13 +76,13 @@ public class ItemEvent extends CustomNPCsEvent { public static class AttackEvent extends ItemEvent { public final int type;//1: Hit, 2: Whiff //TODO: Implement type 2 public final Object target; - public IPlayer player; + public IEntity swingingEntity; - public AttackEvent(ScriptCustomItem item, IPlayer player, int type, Object target) { + public AttackEvent(ScriptCustomItem item, IEntity swingingEntity, int type, Object target) { super(item); this.type = type; this.target = target; - this.player = player; + this.swingingEntity = swingingEntity; } } diff --git a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java index a02ef731f..2407cd8c7 100644 --- a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java @@ -11,6 +11,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.DamageSource; import noppes.npcs.controllers.Dialog; +import noppes.npcs.controllers.ScriptController; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.*; @@ -35,7 +36,7 @@ public class NpcEvent extends CustomNPCsEvent { public CollideEvent(ICustomNpc npc, Entity entity) { super(npc); - this.entity = NpcAPI.Instance().getIEntity(entity); + this.entity = ScriptController.Instance.getScriptForEntity(entity); } } @@ -48,7 +49,7 @@ public class NpcEvent extends CustomNPCsEvent { public DamagedEvent(ICustomNpc npc, Entity source, float damage, DamageSource damagesource) { super(npc); - this.source = NpcAPI.Instance().getIEntity(source); + this.source = ScriptController.Instance.getScriptForEntity(source); this.damage = damage; this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource); } @@ -65,7 +66,7 @@ public class NpcEvent extends CustomNPCsEvent { public RangedLaunchedEvent(ICustomNpc npc, float damage, EntityLivingBase target) { super(npc); - this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target); + this.target = (IEntityLivingBase)ScriptController.Instance.getScriptForEntity(target); this.damage = damage; } } @@ -77,7 +78,7 @@ public class NpcEvent extends CustomNPCsEvent { public MeleeAttackEvent(ICustomNpc npc, float damage, EntityLivingBase target) { super(npc); - this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target); + this.target = (IEntityLivingBase)ScriptController.Instance.getScriptForEntity(target); this.damage = damage; } } @@ -87,7 +88,7 @@ public class NpcEvent extends CustomNPCsEvent { public KilledEntityEvent(ICustomNpc npc, EntityLivingBase entity) { super(npc); - this.entity = (IEntityLivingBase)NpcAPI.Instance().getIEntity(entity); + this.entity = (IEntityLivingBase)ScriptController.Instance.getScriptForEntity(entity); } } @@ -102,7 +103,7 @@ public class NpcEvent extends CustomNPCsEvent { super(npc); this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource); this.type = damagesource.damageType; - this.source = NpcAPI.Instance().getIEntity(entity); + this.source = ScriptController.Instance.getScriptForEntity(entity); } public String getType(){ @@ -116,7 +117,7 @@ public class NpcEvent extends CustomNPCsEvent { public InteractEvent(ICustomNpc npc, EntityPlayer player) { super(npc); - this.player = (IPlayer)NpcAPI.Instance().getIEntity(player); + this.player = (IPlayer)ScriptController.Instance.getScriptForEntity(player); } } @@ -128,7 +129,7 @@ public class NpcEvent extends CustomNPCsEvent { public DialogEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) { super(npc); - this.player = (IPlayer)NpcAPI.Instance().getIEntity(player); + this.player = (IPlayer)ScriptController.Instance.getScriptForEntity(player); this.id = id; this.optionId = optionId; this.dialog = dialog; @@ -143,7 +144,7 @@ public class NpcEvent extends CustomNPCsEvent { public DialogClosedEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) { super(npc); - this.player = (IPlayer)NpcAPI.Instance().getIEntity(player); + this.player = (IPlayer)ScriptController.Instance.getScriptForEntity(player); this.id = id; this.optionId = optionId; this.dialog = dialog; @@ -156,7 +157,7 @@ public class NpcEvent extends CustomNPCsEvent { public TargetLostEvent(ICustomNpc npc, EntityLivingBase entity) { super(npc); - this.entity = (IEntityLivingBase)NpcAPI.Instance().getIEntity(entity); + this.entity = (IEntityLivingBase) ScriptController.Instance.getScriptForEntity(entity); } } @@ -166,7 +167,7 @@ public class NpcEvent extends CustomNPCsEvent { public TargetEvent(ICustomNpc npc, EntityLivingBase entity) { super(npc); - this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity); + this.entity = (IEntityLivingBase) ScriptController.Instance.getScriptForEntity(entity); } } diff --git a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java index a2b53fa4b..0f1dbfb3c 100644 --- a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java @@ -12,6 +12,7 @@ import net.minecraft.entity.item.EntityXPOrb; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.world.World; +import noppes.npcs.controllers.ScriptController; import noppes.npcs.scripted.*; import noppes.npcs.scripted.entity.ScriptLivingBase; import noppes.npcs.scripted.interfaces.*; @@ -133,7 +134,7 @@ public class PlayerEvent extends CustomNPCsEvent { public DamagedEvent(IPlayer player, Entity source, float damage, DamageSource damagesource) { super(player); - this.source = NpcAPI.Instance().getIEntity(source); + this.source = ScriptController.Instance.getScriptForEntity(source); this.damage = damage; this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource); } @@ -194,7 +195,7 @@ public class PlayerEvent extends CustomNPCsEvent { super(player); this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource); this.type = damagesource.getDamageType(); - this.source = NpcAPI.Instance().getIEntity(entity); + this.source = ScriptController.Instance.getScriptForEntity(entity); } } @@ -218,7 +219,7 @@ public class PlayerEvent extends CustomNPCsEvent { public DamagedEntityEvent(IPlayer player, Entity target, float damage, DamageSource damagesource) { super(player); - this.target = NpcAPI.Instance().getIEntity(target); + this.target = ScriptController.Instance.getScriptForEntity(target); this.damage = damage; this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource); } diff --git a/src/main/java/noppes/npcs/scripted/event/ScriptEventDialog.java b/src/main/java/noppes/npcs/scripted/event/ScriptEventDialog.java index 3e8d3bc2f..fd73d1fcc 100644 --- a/src/main/java/noppes/npcs/scripted/event/ScriptEventDialog.java +++ b/src/main/java/noppes/npcs/scripted/event/ScriptEventDialog.java @@ -2,6 +2,7 @@ package noppes.npcs.scripted.event; import net.minecraft.entity.player.EntityPlayer; import noppes.npcs.controllers.Dialog; +import noppes.npcs.controllers.ScriptController; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.IPlayer; @@ -12,7 +13,7 @@ public class ScriptEventDialog extends ScriptEvent{ public Dialog dialogObj; public ScriptEventDialog(EntityPlayer player, int dialog, int option, Dialog dialogObj){ - this.player = (IPlayer)NpcAPI.Instance().getIEntity(player); + this.player = (IPlayer) ScriptController.Instance.getScriptForEntity(player); this.dialog = dialog; this.option = option; this.dialogObj = dialogObj; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java index 4e8eb2f83..b3e2848e7 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java @@ -60,7 +60,7 @@ public interface IWorld { public void playSoundToNearExcept(ScriptPlayer player, String sound, float volume, float pitch); - public ScriptEntity getEntityByID(int id); + public IEntity getEntityByID(int id); public boolean spawnEntityInWorld(ScriptEntity entity); diff --git a/src/main/java/noppes/npcs/scripted/wrapper/ScriptDamageSource.java b/src/main/java/noppes/npcs/scripted/wrapper/ScriptDamageSource.java index 32aecda6c..0f8fe38ac 100644 --- a/src/main/java/noppes/npcs/scripted/wrapper/ScriptDamageSource.java +++ b/src/main/java/noppes/npcs/scripted/wrapper/ScriptDamageSource.java @@ -6,6 +6,7 @@ package noppes.npcs.scripted.wrapper; import net.minecraft.util.DamageSource; +import noppes.npcs.controllers.ScriptController; import noppes.npcs.scripted.interfaces.IDamageSource; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.IEntity; @@ -34,10 +35,10 @@ public class ScriptDamageSource implements IDamageSource { } public IEntity getTrueSource() { - return NpcAPI.Instance().getIEntity(this.source.getEntity()); + return ScriptController.Instance.getScriptForEntity(this.source.getEntity()); } public IEntity getImmediateSource() { - return NpcAPI.Instance().getIEntity(this.source.getSourceOfDamage()); + return ScriptController.Instance.getScriptForEntity(this.source.getSourceOfDamage()); } } diff --git a/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java b/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java index 60b4c4c59..48ab68fc1 100644 --- a/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java @@ -171,9 +171,9 @@ public class WrapperNpcAPI extends NpcAPI { public IItemStack getIItemStack(ItemStack itemstack) { if(itemstack.getItem() instanceof ItemScripted){ - return (ICustomItem) (itemstack != null && itemstack.stackSize > 0 ? new ScriptCustomItem(itemstack) : new ScriptCustomItem(new ItemStack(Item.getItemById(0)))); + return (ICustomItem) (itemstack.stackSize > 0 ? new ScriptCustomItem(itemstack) : new ScriptCustomItem(new ItemStack(Item.getItemById(0)))); } else { - return (IItemStack) (itemstack != null && itemstack.stackSize > 0 ? new ScriptItemStack(itemstack) : new ScriptItemStack(new ItemStack(Item.getItemById(0)))); + return (IItemStack) (itemstack.stackSize > 0 ? new ScriptItemStack(itemstack) : new ScriptItemStack(new ItemStack(Item.getItemById(0)))); } } From aab550cdca455ee176251f22fd6747815cf188a3 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 11 May 2022 14:24:12 -0500 Subject: [PATCH 28/75] Implemented custom item rotation rate, and start using, using, stop using, finished using events for custom items. --- src/main/java/noppes/npcs/EventHooks.java | 29 +++++++-- .../noppes/npcs/ScriptItemEventHandler.java | 48 ++++++++++++++ .../client/gui/script/GuiScriptInterface.java | 4 ++ .../client/renderer/CustomItemRenderer.java | 43 ++++++++++-- .../java/noppes/npcs/items/ItemScripted.java | 16 +---- .../noppes/npcs/scripted/event/ItemEvent.java | 65 +++++++++++++++---- .../npcs/scripted/item/ScriptCustomItem.java | 43 ++++++++++++ 7 files changed, 212 insertions(+), 36 deletions(-) diff --git a/src/main/java/noppes/npcs/EventHooks.java b/src/main/java/noppes/npcs/EventHooks.java index 49d402c3e..d9c755ee3 100644 --- a/src/main/java/noppes/npcs/EventHooks.java +++ b/src/main/java/noppes/npcs/EventHooks.java @@ -36,10 +36,7 @@ import noppes.npcs.scripted.event.PlayerEvent.LoginEvent; import noppes.npcs.scripted.event.PlayerEvent.LogoutEvent; import noppes.npcs.scripted.event.PlayerEvent.PickUpEvent; import noppes.npcs.scripted.event.PlayerEvent.DropEvent; -import noppes.npcs.scripted.interfaces.ICustomGui; -import noppes.npcs.scripted.interfaces.IEntity; -import noppes.npcs.scripted.interfaces.IItemStack; -import noppes.npcs.scripted.interfaces.IWorld; +import noppes.npcs.scripted.interfaces.*; import noppes.npcs.scripted.item.ScriptCustomItem; import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.wrapper.WrapperNpcAPI; @@ -96,6 +93,30 @@ public class EventHooks { return WrapperNpcAPI.EVENT_BUS.post(event); } + public static boolean onStartUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) { + ItemEvent.StartUsingItem event = new ItemEvent.StartUsingItem(handler, player, duration); + handler.callScript(EnumScriptType.START_USING_ITEM, event); + return WrapperNpcAPI.EVENT_BUS.post(event); + } + + public static boolean onUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) { + ItemEvent.UsingItem event = new ItemEvent.UsingItem(handler, player, duration); + handler.callScript(EnumScriptType.USING_ITEM, event); + return WrapperNpcAPI.EVENT_BUS.post(event); + } + + public static boolean onStopUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) { + ItemEvent.StopUsingItem event = new ItemEvent.StopUsingItem(handler, player, duration); + handler.callScript(EnumScriptType.STOP_USING_ITEM, event); + return WrapperNpcAPI.EVENT_BUS.post(event); + } + + public static boolean onFinishUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) { + ItemEvent.FinishUsingItem event = new ItemEvent.FinishUsingItem(handler, player, duration); + handler.callScript(EnumScriptType.FINISH_USING_ITEM, event); + return WrapperNpcAPI.EVENT_BUS.post(event); + } + public static void onNPCInit(EntityNPCInterface npc) { if(npc == null || npc.wrappedNPC == null) return; diff --git a/src/main/java/noppes/npcs/ScriptItemEventHandler.java b/src/main/java/noppes/npcs/ScriptItemEventHandler.java index e21ddd8dc..c5de605c2 100644 --- a/src/main/java/noppes/npcs/ScriptItemEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptItemEventHandler.java @@ -12,10 +12,13 @@ import net.minecraftforge.event.entity.item.ItemTossEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.player.EntityInteractEvent; +import net.minecraftforge.event.entity.player.PlayerUseItemEvent; import noppes.npcs.controllers.ScriptController; +import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.items.ItemScripted; import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.event.ItemEvent; import noppes.npcs.scripted.interfaces.IItemStack; import noppes.npcs.scripted.interfaces.IPlayer; @@ -109,4 +112,49 @@ public class ScriptItemEventHandler { } catch(Exception e) {} } } + + @SubscribeEvent + public void invoke(PlayerUseItemEvent.Start event) { + if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + return; + + if(event.entityPlayer.worldObj instanceof WorldServer) { + ScriptCustomItem handler = ItemScripted.GetWrapper(event.item); + ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + event.setCanceled(EventHooks.onStartUsingCustomItem(handler, scriptPlayer, event.duration)); + } + } + @SubscribeEvent + public void invoke(PlayerUseItemEvent.Tick event) { + if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + return; + + if(event.entityPlayer.worldObj instanceof WorldServer && event.item.getItem() == CustomItems.scripted_item) { + ScriptCustomItem handler = ItemScripted.GetWrapper(event.item); + ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + event.setCanceled(EventHooks.onUsingCustomItem(handler, scriptPlayer, event.duration)); + } + } + @SubscribeEvent + public void invoke(PlayerUseItemEvent.Stop event) { + if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + return; + + if(event.entityPlayer.worldObj instanceof WorldServer && event.item.getItem() == CustomItems.scripted_item) { + ScriptCustomItem handler = ItemScripted.GetWrapper(event.item); + ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + event.setCanceled(EventHooks.onStopUsingCustomItem(handler, scriptPlayer, event.duration)); + } + } + @SubscribeEvent + public void invoke(PlayerUseItemEvent.Finish event) { + if(event.entityPlayer == null || event.entityPlayer.worldObj == null) + return; + + if(event.entityPlayer.worldObj instanceof WorldServer && event.item.getItem() == CustomItems.scripted_item) { + ScriptCustomItem handler = ItemScripted.GetWrapper(event.item); + ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + EventHooks.onFinishUsingCustomItem(handler, scriptPlayer, event.duration); + } + } } diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java index 7e6100906..21183687c 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java @@ -173,6 +173,10 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb hookList.add("spawn"); hookList.add("interact"); hookList.add("attack"); + hookList.add("startItem"); + hookList.add("usingItem"); + hookList.add("stopItem"); + hookList.add("finishItem"); //hookList.add(""); //hookList.add(""); } diff --git a/src/main/java/noppes/npcs/client/renderer/CustomItemRenderer.java b/src/main/java/noppes/npcs/client/renderer/CustomItemRenderer.java index d875ec1d4..488ecc496 100644 --- a/src/main/java/noppes/npcs/client/renderer/CustomItemRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/CustomItemRenderer.java @@ -6,7 +6,6 @@ import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.resources.IResource; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; @@ -33,7 +32,8 @@ public class CustomItemRenderer implements IItemRenderer { private static final ResourceLocation enchant = new ResourceLocation("textures/misc/enchanted_item_glint.png"); private final Random random = new Random(); - private int itemRenderTicks = 0; + private int entityRenderTicks = 1; + private int item3dRenderTicks = 1; @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { @@ -80,7 +80,22 @@ public class CustomItemRenderer implements IItemRenderer { } if (type == ItemRenderType.ENTITY) { - ((ItemScripted) itemStack.getItem()).renderCustomAttributes(itemStack); + GL11.glRotatef(scriptCustomItem.rotationX, 1, 0, 0); + GL11.glRotatef(scriptCustomItem.rotationY, 0, 1, 0); + GL11.glRotatef(scriptCustomItem.rotationZ, 0, 0, 1); + + GL11.glRotatef(scriptCustomItem.rotationXRate * entityRenderTicks%360, 1, 0, 0); + GL11.glRotatef(scriptCustomItem.rotationYRate * entityRenderTicks%360, 0, 1, 0); + GL11.glRotatef(scriptCustomItem.rotationZRate * entityRenderTicks%360, 0, 0, 1); + + GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ); + + int color = scriptCustomItem.getColor(); + float itemRed = (color >> 16 & 255) / 255f; + float itemGreen = (color >> 8 & 255) / 255f; + float itemBlue = (color & 255) / 255f; + GL11.glColor4f(itemRed, itemGreen, itemBlue, 1.0F); + EntityItem entityItem = (EntityItem) data[1]; renderEntityCustomItem(scriptCustomItem, itemStack, entityItem); return; @@ -91,7 +106,21 @@ public class CustomItemRenderer implements IItemRenderer { ((ItemRenderInterface) itemStack.getItem()).renderSpecial(); GL11.glTranslatef(scriptCustomItem.translateX, scriptCustomItem.translateY, scriptCustomItem.translateZ); - ((ItemScripted) itemStack.getItem()).renderCustomAttributes(itemStack); + GL11.glRotatef(scriptCustomItem.rotationX, 1, 0, 0); + GL11.glRotatef(scriptCustomItem.rotationY, 0, 1, 0); + GL11.glRotatef(scriptCustomItem.rotationZ, 0, 0, 1); + + GL11.glRotatef(scriptCustomItem.rotationXRate * item3dRenderTicks %360, 1, 0, 0); + GL11.glRotatef(scriptCustomItem.rotationYRate * item3dRenderTicks %360, 0, 1, 0); + GL11.glRotatef(scriptCustomItem.rotationZRate * item3dRenderTicks %360, 0, 0, 1); + + GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ); + + int color = scriptCustomItem.getColor(); + float itemRed = (color >> 16 & 255) / 255f; + float itemGreen = (color >> 8 & 255) / 255f; + float itemBlue = (color & 255) / 255f; + GL11.glColor4f(itemRed, itemGreen, itemBlue, 1.0F); GL11.glRotatef(-20.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F); @@ -102,9 +131,9 @@ public class CustomItemRenderer implements IItemRenderer { } public void renderEntityCustomItem(ScriptCustomItem scriptCustomItem, ItemStack itemStack, EntityItem entityItem) { - this.itemRenderTicks++; + this.entityRenderTicks++; int pass = 0; - float bobbingY = (float)(Math.sin((float)this.itemRenderTicks/40.0F) + 1) * scriptCustomItem.scaleY/6.0F; + float bobbingY = (float)(Math.sin((float)this.entityRenderTicks /40.0F) + 1) * scriptCustomItem.scaleY/6.0F; GL11.glPushMatrix(); GL11.glTranslatef(0.0F, bobbingY, 0.0F); @@ -342,6 +371,8 @@ public class CustomItemRenderer implements IItemRenderer { } public void renderItem3d(ScriptCustomItem scriptCustomItem, EntityLivingBase entityLivingBase, ItemStack itemStack) { + item3dRenderTicks++; + Minecraft mc = Minecraft.getMinecraft(); TextureManager texturemanager = mc.getTextureManager(); int par3 = 0; diff --git a/src/main/java/noppes/npcs/items/ItemScripted.java b/src/main/java/noppes/npcs/items/ItemScripted.java index 43b941229..510c8fbbc 100644 --- a/src/main/java/noppes/npcs/items/ItemScripted.java +++ b/src/main/java/noppes/npcs/items/ItemScripted.java @@ -4,6 +4,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -161,19 +162,4 @@ public class ItemScripted extends Item implements ItemRenderInterface { public void renderSpecial() { GL11.glTranslatef(0.135F, 0.2F, 0.07F); } - - public void renderCustomAttributes(ItemStack itemStack) { - ScriptCustomItem scriptCustomItem = GetWrapper(itemStack); - - GL11.glRotatef(scriptCustomItem.rotationX, 1, 0, 0); - GL11.glRotatef(scriptCustomItem.rotationY, 0, 1, 0); - GL11.glRotatef(scriptCustomItem.rotationZ, 0, 0, 1); - GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ); - - int color = scriptCustomItem.getColor(); - float itemRed = (color >> 16 & 255) / 255f; - float itemGreen = (color >> 8 & 255) / 255f; - float itemBlue = (color & 255) / 255f; - GL11.glColor4f(itemRed, itemGreen, itemBlue, 1.0F); - } } diff --git a/src/main/java/noppes/npcs/scripted/event/ItemEvent.java b/src/main/java/noppes/npcs/scripted/event/ItemEvent.java index 6bbb8c4e3..87663eada 100644 --- a/src/main/java/noppes/npcs/scripted/event/ItemEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/ItemEvent.java @@ -1,20 +1,23 @@ package noppes.npcs.scripted.event; import cpw.mods.fml.common.eventhandler.Cancelable; -import noppes.npcs.scripted.entity.ScriptEntity; +import net.minecraft.item.ItemStack; +import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.interfaces.ICustomItem; import noppes.npcs.scripted.interfaces.IEntity; +import noppes.npcs.scripted.interfaces.IItemStack; import noppes.npcs.scripted.interfaces.IPlayer; import noppes.npcs.scripted.item.ScriptCustomItem; public class ItemEvent extends CustomNPCsEvent { - public ScriptCustomItem item; + public ICustomItem item; - public ItemEvent(ScriptCustomItem item) { + public ItemEvent(ICustomItem item) { this.item = item; } public static class InitEvent extends ItemEvent { - public InitEvent(ScriptCustomItem item) { + public InitEvent(ICustomItem item) { super(item); } } @@ -22,7 +25,7 @@ public class ItemEvent extends CustomNPCsEvent { public static class UpdateEvent extends ItemEvent { public IEntity entity; - public UpdateEvent(ScriptCustomItem item, IEntity entity) { + public UpdateEvent(ICustomItem item, IEntity entity) { super(item); this.entity = entity; } @@ -33,7 +36,7 @@ public class ItemEvent extends CustomNPCsEvent { public IEntity entity; public IPlayer player; - public TossedEvent(ScriptCustomItem item, IPlayer player, IEntity entity) { + public TossedEvent(ICustomItem item, IPlayer player, IEntity entity) { super(item); this.entity = entity; this.player = player; @@ -43,7 +46,7 @@ public class ItemEvent extends CustomNPCsEvent { public static class PickedUpEvent extends ItemEvent { public IPlayer player; - public PickedUpEvent(ScriptCustomItem item, IPlayer player) { + public PickedUpEvent(ICustomItem item, IPlayer player) { super(item); this.player = player; } @@ -52,7 +55,7 @@ public class ItemEvent extends CustomNPCsEvent { @Cancelable public static class SpawnEvent extends ItemEvent { public IEntity entity; - public SpawnEvent(ScriptCustomItem item, IEntity entity){ + public SpawnEvent(ICustomItem item, IEntity entity){ super(item); this.entity = entity; } @@ -64,7 +67,7 @@ public class ItemEvent extends CustomNPCsEvent { public final Object target; public IPlayer player; - public InteractEvent(ScriptCustomItem item, IPlayer player, int type, Object target) { + public InteractEvent(ICustomItem item, IPlayer player, int type, Object target) { super(item); this.type = type; this.target = target; @@ -74,11 +77,11 @@ public class ItemEvent extends CustomNPCsEvent { @Cancelable public static class AttackEvent extends ItemEvent { - public final int type;//1: Hit, 2: Whiff //TODO: Implement type 2 + public final int type;//1: Hit, 2: Whiff public final Object target; public IEntity swingingEntity; - public AttackEvent(ScriptCustomItem item, IEntity swingingEntity, int type, Object target) { + public AttackEvent(ICustomItem item, IEntity swingingEntity, int type, Object target) { super(item); this.type = type; this.target = target; @@ -86,4 +89,44 @@ public class ItemEvent extends CustomNPCsEvent { } } + public static class StartUsingItem extends ItemEvent { + public final IPlayer player; + public final int duration; + + public StartUsingItem(ICustomItem item, IPlayer player, int duration){ + super(item); + this.player = player; + this.duration = duration; + } + } + public static class UsingItem extends ItemEvent { + public final IPlayer player; + public final int duration; + + public UsingItem(ICustomItem item, IPlayer player, int duration){ + super(item); + this.player = player; + this.duration = duration; + } + } + public static class StopUsingItem extends ItemEvent { + public final IPlayer player; + public final int duration; + + public StopUsingItem(ICustomItem item, IPlayer player, int duration){ + super(item); + this.player = player; + this.duration = duration; + } + } + public static class FinishUsingItem extends ItemEvent { + public final IPlayer player; + public final int duration; + + public FinishUsingItem(ICustomItem item, IPlayer player, int duration){ + super(item); + this.player = player; + this.duration = duration; + } + } } diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java index b9320b729..b3233840f 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java @@ -41,6 +41,7 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS public float translateX, translateY, translateZ; public float scaleX = 1.0F, scaleY = 1.0F, scaleZ = 1.0F; public float rotationX, rotationY, rotationZ; + public float rotationXRate, rotationYRate, rotationZRate; public ScriptCustomItem(ItemStack item) { super(item); @@ -273,6 +274,13 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS saveItemData(); } + public void setRotationRate(float rotationXRate, float rotationYRate, float rotationZRate){ + this.rotationXRate = rotationXRate; + this.rotationYRate = rotationYRate; + this.rotationZRate = rotationZRate; + saveItemData(); + } + public void setScale(float scaleX, float scaleY, float scaleZ){ this.scaleX = scaleX; this.scaleY = scaleY; @@ -302,6 +310,21 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS saveItemData(); } + public void setRotationXRate(float rotationXRate) { + this.rotationXRate = rotationXRate; + saveItemData(); + } + + public void setRotationYRate(float rotationYRate) { + this.rotationYRate = rotationYRate; + saveItemData(); + } + + public void setRotationZRate(float rotationZRate) { + this.rotationZRate = rotationZRate; + saveItemData(); + } + public void setScaleX(float scaleX) { this.scaleX = scaleX; saveItemData(); @@ -344,6 +367,18 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS return rotationZ; } + public float getRotationXRate() { + return rotationXRate; + } + + public float getRotationYRate() { + return rotationYRate; + } + + public float getRotationZRate() { + return rotationZRate; + } + public float getScaleX() { return scaleX; } @@ -392,6 +427,10 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS compound.setFloat("RotationY",this.rotationY); compound.setFloat("RotationZ",this.rotationZ); + compound.setFloat("RotationXRate",this.rotationXRate); + compound.setFloat("RotationYRate",this.rotationYRate); + compound.setFloat("RotationZRate",this.rotationZRate); + compound.setFloat("ScaleX",this.scaleX); compound.setFloat("ScaleY",this.scaleY); compound.setFloat("ScaleZ",this.scaleZ); @@ -427,6 +466,10 @@ public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IS this.rotationY = compound.getFloat("RotationY"); this.rotationZ = compound.getFloat("RotationZ"); + this.rotationXRate = compound.getFloat("RotationXRate"); + this.rotationYRate = compound.getFloat("RotationYRate"); + this.rotationZRate = compound.getFloat("RotationZRate"); + this.scaleX = compound.getFloat("ScaleX"); this.scaleY = compound.getFloat("ScaleY"); this.scaleZ = compound.getFloat("ScaleZ"); From c2546c3f820e63e120ce0267f634d0edb3f605ec Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 11 May 2022 16:31:14 -0500 Subject: [PATCH 29/75] Updated interfaces to have the proper functions. Documentation will focus around them, so they'll be better organized from now on. --- .../gui/custom/components/CustomGuiLabel.java | 10 +- .../npcs/scripted/entity/ScriptEntity.java | 5 + .../npcs/scripted/entity/ScriptNpc.java | 2 + .../npcs/scripted/entity/ScriptPlayer.java | 1 + .../npcs/scripted/gui/ScriptGuiLabel.java | 8 +- .../npcs/scripted/interfaces/IBlock.java | 11 + .../npcs/scripted/interfaces/ICustomGui.java | 12 + .../interfaces/ICustomGuiComponent.java | 19 ++ .../npcs/scripted/interfaces/ICustomItem.java | 80 +++++ .../npcs/scripted/interfaces/ICustomNpc.java | 315 +++++++++--------- .../scripted/interfaces/ICustomOverlay.java | 34 ++ .../interfaces/ICustomOverlayComponent.java | 7 + .../scripted/interfaces/IDamageSource.java | 2 + .../npcs/scripted/interfaces/IEntity.java | 172 +++++++--- .../interfaces/IEntityLivingBase.java | 45 ++- .../npcs/scripted/interfaces/IItemStack.java | 76 +++-- .../npcs/scripted/interfaces/ILabel.java | 4 + .../scripted/interfaces/IOverlayLabel.java | 4 + .../npcs/scripted/interfaces/IPixelmon.java | 92 +++++ .../npcs/scripted/interfaces/IPlayer.java | 133 ++++++-- .../npcs/scripted/interfaces/IWorld.java | 120 +++---- .../npcs/scripted/overlay/ScriptOverlay.java | 4 - 22 files changed, 801 insertions(+), 355 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java index 798d6dd16..f98ec1411 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java @@ -9,10 +9,7 @@ import com.ibm.icu.text.ArabicShaping; import com.ibm.icu.text.ArabicShapingException; import com.ibm.icu.text.Bidi; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiLabel; -import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.ResourceLocation; import noppes.npcs.client.gui.custom.GuiCustom; @@ -25,7 +22,6 @@ import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; public class CustomGuiLabel extends Gui implements IGuiComponent { int x, y, width, height; @@ -135,14 +131,14 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { } public static CustomGuiLabel fromComponent(ScriptGuiLabel component) { - CustomGuiLabel lbl = new CustomGuiLabel(component.getID(), component.getText(), GuiCustom.guiLeft + component.getPosX(), GuiCustom.guiTop + component.getPosY(), component.getWidth(), component.getHeight(), component.hasShadow()); + CustomGuiLabel lbl = new CustomGuiLabel(component.getID(), component.getText(), GuiCustom.guiLeft + component.getPosX(), GuiCustom.guiTop + component.getPosY(), component.getWidth(), component.getHeight(), component.getShadow()); lbl.scale = 1.0F; lbl.color = component.getColor(); lbl.setScale(component.getScale()); if (component.hasHoverText()) { lbl.hoverText = component.getHoverText(); } - lbl.labelShadowEnabled = component.hasShadow(); + lbl.labelShadowEnabled = component.getShadow(); lbl.color = component.getColor(); lbl.alpha = component.getAlpha(); lbl.rotation = component.getRotation(); @@ -155,7 +151,7 @@ public class CustomGuiLabel extends Gui implements IGuiComponent { public ICustomGuiComponent toComponent() { ScriptGuiLabel component = new ScriptGuiLabel(this.id, this.fullLabel, this.field_146162_g, this.field_146174_h, this.field_146167_a, this.field_146161_f, this.color); component.setHoverText(this.hoverText); - component.enableShadow(this.labelShadowEnabled); + component.setShadow(this.labelShadowEnabled); component.setColor(this.color); component.setAlpha(this.alpha); component.setRotation(this.rotation); diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index bad3c2e98..8b6cf2339 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -200,6 +200,7 @@ public class ScriptEntity implements IEntity { entityID, entity.dimension ); } + public void spawnParticle(ScriptParticle entityParticle) { entityParticle.spawnOnEntity(this); } public int getEntityId(){ @@ -357,6 +358,10 @@ public class ScriptEntity implements IEntity { this.entity.setPosition((double)((float)pos.getX() + 0.5F), (double)pos.getY(), (double)((float)pos.getZ() + 0.5F)); } + public int getDimension(){ + return entity.dimension; + } + /** * @param range The search range for entities around this entity * @return Array of entities within range diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index 8bf9aa846..cbfccf986 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -317,6 +317,7 @@ public class ScriptNpc extends ScriptLiving imp return new ScriptRoleTransporter(npc); return new ScriptRoleInterface(npc); } + public void setRole(int role){ for (EnumRoleType e : EnumRoleType.values()) { if (e.ordinal() == role) { @@ -348,6 +349,7 @@ public class ScriptNpc extends ScriptLiving imp return new ScriptJobSpawner(npc); return new ScriptJobInterface(npc); } + public void setJob(int job){ for (EnumJobType e : EnumJobType.values()) { if (e.ordinal() == job) { diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index cacb5dfbd..1aa268b86 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -449,6 +449,7 @@ public class ScriptPlayer extends ScriptLivingBase questData.checkQuestCompletion(playerData, EnumQuestType.Item); } + @Deprecated public boolean checkGUIOpen() { NoppesUtilPlayer.isGUIOpen(player); PlayerData data = PlayerDataController.instance.getPlayerData(player); diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLabel.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLabel.java index bba1444d2..53ade2d95 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLabel.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLabel.java @@ -20,7 +20,7 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel { this.setText(label); this.setPos(x, y); this.setSize(width, height); - this.enableShadow(false); + this.setShadow(false); } public ScriptGuiLabel(int id, String label, int x, int y, int width, int height, int color) { @@ -60,11 +60,11 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel { return this; } - public boolean hasShadow(){ + public boolean getShadow(){ return this.shadow; } - public void enableShadow(boolean shadow){ + public void setShadow(boolean shadow){ this.shadow = shadow; } @@ -86,7 +86,7 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel { this.setText(nbt.getString("label")); this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]); this.setScale(nbt.getFloat("scale")); - this.enableShadow(nbt.getBoolean("shadow")); + this.setShadow(nbt.getBoolean("shadow")); return this; } } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java b/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java index bb84849df..5080ad2ae 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java @@ -6,7 +6,10 @@ package noppes.npcs.scripted.interfaces; import net.minecraft.block.Block; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.ScriptTileEntity; public interface IBlock { int getX(); @@ -33,9 +36,17 @@ public interface IBlock { IWorld getWorld(); + boolean hasTileEntity(); + + ScriptTileEntity getTileEntity(); + + void setTileEntity(ScriptTileEntity tileEntity); + TileEntity getMCTileEntity(); Block getMCBlock(); String getDisplayName(); + + INbt getTileEntityNBT(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ICustomGui.java b/src/main/java/noppes/npcs/scripted/interfaces/ICustomGui.java index 2f803b32e..bb927e68d 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ICustomGui.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ICustomGui.java @@ -5,6 +5,8 @@ package noppes.npcs.scripted.interfaces; +import net.minecraft.nbt.NBTTagCompound; + import java.util.List; public interface ICustomGui { @@ -61,4 +63,14 @@ public interface ICustomGui { void updateComponent(ICustomGuiComponent var1); void update(IPlayer var1); + + boolean getShowPlayerInv(); + + int getPlayerInvX(); + + int getPlayerInvY(); + + ICustomGui fromNBT(NBTTagCompound tag); + + NBTTagCompound toNBT(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ICustomGuiComponent.java b/src/main/java/noppes/npcs/scripted/interfaces/ICustomGuiComponent.java index b7f6474c9..d0294878f 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ICustomGuiComponent.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ICustomGuiComponent.java @@ -5,6 +5,9 @@ package noppes.npcs.scripted.interfaces; +import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.scripted.gui.ScriptGuiComponent; + public interface ICustomGuiComponent { int getID(); @@ -23,4 +26,20 @@ public interface ICustomGuiComponent { ICustomGuiComponent setHoverText(String var1); ICustomGuiComponent setHoverText(String[] var1); + + int getColor(); + + ICustomGuiComponent setColor(int color); + + float getAlpha(); + + void setAlpha(float alpha); + + float getRotation(); + + void setRotation(float rotation); + + NBTTagCompound toNBT(NBTTagCompound nbt); + + ScriptGuiComponent fromNBT(NBTTagCompound nbt); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ICustomItem.java b/src/main/java/noppes/npcs/scripted/interfaces/ICustomItem.java index 07af3cc20..188471230 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ICustomItem.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ICustomItem.java @@ -1,10 +1,22 @@ package noppes.npcs.scripted.interfaces; +import net.minecraft.nbt.NBTTagCompound; + public interface ICustomItem extends IItemStack { String getTexture(); void setTexture(String var2); + int getArmorType(); + + void setIsTool(boolean isTool); + + boolean isTool(); + + void setDigSpeed(int digSpeed); + + int getDigSpeed(); + void setMaxStackSize(int var1); double getDurabilityValue(); @@ -22,4 +34,72 @@ public interface ICustomItem extends IItemStack { int getColor(); void setColor(int var1); + + int getMaxItemUseDuration(); + + void setMaxItemUseDuration(int duration); + + void setItemUseAction(int action); + + int getItemUseAction(); + + int getEnchantability(); + + void setEnchantability(int enchantability); + + void setRotation(float rotationX, float rotationY, float rotationZ); + + void setRotationRate(float rotationXRate, float rotationYRate, float rotationZRate); + + void setScale(float scaleX, float scaleY, float scaleZ); + + void setTranslate(float translateX, float translateY, float translateZ); + + void setRotationX(float rotationX); + + void setRotationY(float rotationY); + + void setRotationZ(float rotationZ); + + void setRotationXRate(float rotationXRate); + + void setRotationYRate(float rotationYRate); + + void setRotationZRate(float rotationZRate); + + void setScaleX(float scaleX); + + void setScaleY(float scaleY); + + void setScaleZ(float scaleZ); + + void setTranslateX(float translateX); + + void setTranslateY(float translateY); + + void setTranslateZ(float translateZ); + + float getRotationX(); + + float getRotationY(); + + float getRotationZ(); + + float getRotationXRate(); + + float getRotationYRate(); + + float getRotationZRate(); + + float getScaleX(); + + float getScaleY(); + + float getScaleZ(); + + float getTranslateX(); + + float getTranslateY(); + + float getTranslateZ(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java b/src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java index 11f5dd9e6..1e2b0596e 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java @@ -16,337 +16,346 @@ public interface ICustomNpc extends IEntityLiving { /** * @return Returns the current npcs size 1-30 */ - public int getSize(); + int getSize(); /** * @param size The size of the npc (1-30) default is 5 */ - public void setSize(int size); + void setSize(int size); /** * @return Returns the current npcs modelType of the NPC */ - public int getModelType(); + int getModelType(); /** * @param modelType The modelType of the NPC. 0: Steve, 1: Steve64, 2: Alex */ - public void setModelType(int modelType); + void setModelType(int modelType); /** * @return The npcs name */ - public String getName(); + String getName(); - public void setRotation(float rotation); + void setRotation(float rotation); + + void setRotationType(int rotationType); + + int getRotationType(); + /** * @param name The name of the npc */ - public void setName(String name); + void setName(String name); /** * @since 1.7.10 * @return The npcs title */ - public String getTitle(); + String getTitle(); /** * @since 1.7.10 * @param title The title of the npc */ - public void setTitle(String title); + void setTitle(String title); /** * @return The npcs texture */ - public String getTexture(); + String getTexture(); /** * @param texture The texture of the npc */ - public void setTexture(String texture); + void setTexture(String texture); /** * @return Home position x */ - public int getHomeX(); + int getHomeX(); /** * @param x The home x position */ - public void setHomeX(int x); + void setHomeX(int x); /** * @return Home position x */ - public int getHomeY(); + int getHomeY(); /** * @param y The home y position */ - public void setHomeY(int y); + void setHomeY(int y); /** * @return Home position x */ - public int getHomeZ(); + int getHomeZ(); /** * @param z The home x position */ - public void setHomeZ(int z); + void setHomeZ(int z); /** * @param x The home x position * @param y The home y position * @param z The home z position */ - public void setHome(int x, int y, int z); + void setHome(int x, int y, int z); /** * @param health New max health */ - public void setMaxHealth(double health); + void setMaxHealth(double health); /** * @param bo Whether or not the npc will try to return to his home position */ - public void setReturnToHome(boolean bo); + void setReturnToHome(boolean bo); /** * @return Whether or not the npc returns home */ - public boolean getReturnToHome(); + boolean getReturnToHome(); /** * @return The faction of the npc */ - public ScriptFaction getFaction(); + ScriptFaction getFaction(); /** * @param id The id of the new faction */ - public void setFaction(int id); + void setFaction(int id); /** * * @param attackOtherFactions True if you want the NPC to attack other factions, false otherwise. */ - public void setAttackFactions(boolean attackOtherFactions); + void setAttackFactions(boolean attackOtherFactions); /** * * @return Returns true if the NPC attacks other factions, false otherwise. */ - public boolean getAttackFactions(); + boolean getAttackFactions(); /** * * @param defendFaction True if the NPC should defend faction members, false otherwise. */ - public void setDefendFaction(boolean defendFaction); + void setDefendFaction(boolean defendFaction); /** * * @return Returns true if the NPC should defend faction members, false otherwise. */ - public boolean getDefendFaction(); + boolean getDefendFaction(); - public int getType(); + int getType(); - public boolean typeOf(int type); + boolean typeOf(int type); /** * @param target The targeted npc * @param item The item you want to shoot * @param accuracy Accuracy of the shot (0-100) */ - public void shootItem(ScriptLivingBase target, ScriptItemStack item, int accuracy); + void shootItem(ScriptLivingBase target, ScriptItemStack item, int accuracy); /** * @param message The message the npc will say */ - public void say(String message); + void say(String message); /** * @param message The message the npc will say */ - public void say(ScriptPlayer player, String message); + void say(ScriptPlayer player, String message); /** * Kill the npc, doesnt't despawn it */ - public void kill(); + void kill(); /** * Basically completely resets the npc. This will also call the Init script */ - public void reset(); + void reset(); /** * @return Returns the npcs current role */ - public ScriptRoleInterface getRole(); + ScriptRoleInterface getRole(); + + void setRole(int role); /** * @return Returns the npcs current job */ - public ScriptJobInterface getJob(); + ScriptJobInterface getJob(); + + void setJob(int job); /** * @return The item held in the right hand */ - public IItemStack getRightItem(); + IItemStack getRightItem(); /** * @param item Item to be held in the right hand */ - public void setRightItem(ScriptItemStack item); + void setRightItem(ScriptItemStack item); /** * @return The item held in the left hand */ - public IItemStack getLefttItem(); + IItemStack getLefttItem(); /** * @param item Item to be held in the left hand */ - public void setLeftItem(ScriptItemStack item); + void setLeftItem(ScriptItemStack item); /** * @return Returns the projectile the npc uses */ - public IItemStack getProjectileItem(); + IItemStack getProjectileItem(); /** * @param item Item to be used as projectile */ - public void setProjectileItem(ScriptItemStack item); + void setProjectileItem(ScriptItemStack item); /** * * @return Returns true if the NPC can aim while shooting. */ - public boolean canAimWhileShooting(); + boolean canAimWhileShooting(); /** * * @param aimWhileShooting Set to true if you want the NPC to aim while shooting, false otherwise. */ - public void aimWhileShooting(boolean aimWhileShooting); + void aimWhileShooting(boolean aimWhileShooting); - public void setMinProjectileDelay(int minDelay); - public int getMinProjectileDelay(); + void setMinProjectileDelay(int minDelay); + int getMinProjectileDelay(); - public void setMaxProjectileDelay(int maxDelay); - public int getMaxProjectileDelay(); + void setMaxProjectileDelay(int maxDelay); + int getMaxProjectileDelay(); - public void setRangedRage(int rangedRange); - public int getRangedRage(); + void setRangedRage(int rangedRange); + int getRangedRage(); - public void setFireRate(int rate); - public int getFireRate(); + void setFireRate(int rate); + int getFireRate(); - public void setBurstCount(int burstCount); - public int getBurstCount(); + void setBurstCount(int burstCount); + int getBurstCount(); - public void setShotCount(int shotCount); - public int getShotCount(); + void setShotCount(int shotCount); + int getShotCount(); - public void setAccuracy(int accuracy); - public int getAccuracy(); + void setAccuracy(int accuracy); + int getAccuracy(); /** * * @return The directory of the sound that plays when a projectile is shot */ - public String getFireSound(); + String getFireSound(); /** * * @param fireSound The new directory of the sound that plays when a projectile is shot */ - public void setFireSound(String fireSound); + void setFireSound(String fireSound); /** * @param slot The armor slot to return. 0:head, 1:body, 2:legs, 3:boots * @return Returns the worn armor in slot */ - public IItemStack getArmor(int slot); + IItemStack getArmor(int slot); /** * @param slot The armor slot to set. 0:head, 1:body, 2:legs, 3:boots * @param item Item to be set as armor */ - public void setArmor(int slot, ScriptItemStack item); + void setArmor(int slot, ScriptItemStack item); /** * * @param slot The slot from the NPC's drop list to return (0-8) * @return The item in the NPC's drop list slot */ - public IItemStack getLootItem(int slot); + IItemStack getLootItem(int slot); /** * * @param slot The slot from the NPC's drop list to change * @param item The item the drop list slot will be changed to */ - public void setLootItem(int slot, ScriptItemStack item); + void setLootItem(int slot, ScriptItemStack item); /** * * @param slot The slot from the NPC's drop list to return (0-8) * @return The chance of dropping the item in this slot. Returns 100 if the slot is not found. */ - public double getLootChance(int slot); + double getLootChance(int slot); /** * * @param slot The slot from the NPC's drop list to change * @param chance The new chance of dropping the item in this slot */ - public void setLootChance(int slot, double chance); + void setLootChance(int slot, double chance); /** * * @return The NPC's loot mode. 0 = Normal, 1 = Auto Pickup */ - public int getLootMode(); + int getLootMode(); /** * * @param lootMode The NPC's loot mode. 0 = Normal, 1 = Auto Pickup */ - public void setLootMode(int lootMode); + void setLootMode(int lootMode); /** * * @param lootXP The new minimum XP gained from killing the NPC. If greater than the max XP, it will be set to it. */ - public void setMinLootXP(int lootXP); + void setMinLootXP(int lootXP); /** * * @param lootXP The new maximum XP gained from killing the NPC. If less than the min XP, it will be set to it. */ - public void setMaxLootXP(int lootXP); + void setMaxLootXP(int lootXP); /** * * @return The minimum XP gained from killing the NPC. */ - public int getMinLootXP(); + int getMinLootXP(); /** * * @return The maximum XP gained from killing the NPC. */ - public int getMaxLootXP(); + int getMaxLootXP(); /** * @param type The AnimationType */ - public void setAnimation(int type); + void setAnimation(int type); /** * @@ -360,7 +369,7 @@ public interface ICustomNpc extends IEntityLiving { * 6 - None * */ - public void setTacticalVariant(int variant); + void setTacticalVariant(int variant); /** * @@ -374,43 +383,43 @@ public interface ICustomNpc extends IEntityLiving { * 6 - None * */ - public int getTacticalVariant(); + int getTacticalVariant(); /** * * @param variant Sets the NPC's tactical variant by name. */ - public void setTacticalVariant(String variant); + void setTacticalVariant(String variant); /** * * @return Returns the name of the NPc's tactical variant. */ - public String getTacticalVariantName(); + String getTacticalVariantName(); /** * * @param tacticalRadius Sets the radius in which the tactical variant is affected, if any. Effective for all tactical variants except Rush and None. */ - public void setTacticalRadius(int tacticalRadius); + void setTacticalRadius(int tacticalRadius); /** * * @return Gets the radius in which the tactical variant is affected, if any. Effective for all tactical variants except Rush and None. */ - public int getTacticalRadius(); + int getTacticalRadius(); /** * * @param ignore True if the NPC goes through cobwebs */ - public void setIgnoreCobweb(boolean ignore); + void setIgnoreCobweb(boolean ignore); /** * * @return True if the NPC goes through cobwebs */ - public boolean getIgnoreCobweb(); + boolean getIgnoreCobweb(); /** * @@ -420,7 +429,7 @@ public interface ICustomNpc extends IEntityLiving { * 2 - Retreat * 3 - Nothing */ - public void setOnFoundEnemy(int onAttack); + void setOnFoundEnemy(int onAttack); /** * @@ -430,7 +439,7 @@ public interface ICustomNpc extends IEntityLiving { * 2 - Retreat * 3 - Nothing */ - public int onFoundEnemy(); + int onFoundEnemy(); /** * @@ -439,7 +448,7 @@ public interface ICustomNpc extends IEntityLiving { * 1 - Sunlight * 2 - Disabled */ - public void setShelterFrom(int shelterFrom); + void setShelterFrom(int shelterFrom); /** * @@ -448,36 +457,36 @@ public interface ICustomNpc extends IEntityLiving { * 1 - Sunlight * 2 - Disabled */ - public int getShelterFrom(); + int getShelterFrom(); /** * * @return Whether the NPC has a living animation */ - public boolean hasLivingAnimation(); + boolean hasLivingAnimation(); /** * * @param livingAnimation True if you want the NPC to have a living animation, false otherwise */ - public void setLivingAnimation(boolean livingAnimation); + void setLivingAnimation(boolean livingAnimation); /** * @param type The visibility type of the npc, 0:visible, 1:invisible, 2:semi-visible */ - public void setVisibleType(int type); + void setVisibleType(int type); /** * @return The visibility type of the npc, 0:visible, 1:invisible, 2:semi-visible */ - public int getVisibleType(); + int getVisibleType(); /** * * @param player The player this NPC becomes visible/invisible to * @param visible True if you want the NPC to be invisible to the player, false otherwise */ - public void setVisibleTo(ScriptPlayer player, boolean visible); + void setVisibleTo(ScriptPlayer player, boolean visible); /** * @@ -486,251 +495,253 @@ public interface ICustomNpc extends IEntityLiving { * If setVisibleTo(player,visible) was not called to make this NPC invisible to the player at any point * in the NPC's life, this function will return true regardless of the value of isVisible(). */ - public boolean isVisibleTo(ScriptPlayer player); + boolean isVisibleTo(ScriptPlayer player); /** * @param type The visibility type of the name, 0:visible, 1:invisible, 2:when-attacking */ - public void setShowName(int type); + void setShowName(int type); /** * @return Returns the visibility type of the name, 0:visible, 1:invisible, 2:when-attacking */ - public int getShowName(); + int getShowName(); /** * @return Returns the visiblity of the boss bar, 0:invisible, 1:visible, 2:when-attacking */ - public int getShowBossBar(); + int getShowBossBar(); /** * @param type The visibility type of the boss bar, 0:invisible, 1:visible, 2:when-attacking */ - public void setShowBossBar(int type); + void setShowBossBar(int type); /** * @return The melee strength */ - public float getMeleeStrength(); + float getMeleeStrength(); /** * @param strength The melee strength */ - public void setMeleeStrength(float strength); + void setMeleeStrength(float strength); /** * @return The melee speed */ - public int getMeleeSpeed(); + int getMeleeSpeed(); /** * @param speed The melee speed */ - public void setMeleeSpeed(int speed); + void setMeleeSpeed(int speed); /** * @return The ranged strength */ - public float getRangedStrength(); + float getRangedStrength(); /** * @param strength The ranged strength */ - public void setRangedStrength(float strength); + void setRangedStrength(float strength); /** * @return The ranged speed */ - public int getRangedSpeed(); + int getRangedSpeed(); /** * @param speed The ranged speed */ - public void setRangedSpeed(int speed); + void setRangedSpeed(int speed); /** * @return The ranged burst count */ - public int getRangedBurst(); + int getRangedBurst(); /** * @param count The ranged burst count */ - public void setRangedBurst(int count); + void setRangedBurst(int count); /** * * @return The amount of ticks before this entity respawns */ - public int getRespawnTime(); + int getRespawnTime(); /** * * @param time The new amount of ticks before this entity respawns */ - public void setRespawnTime(int time); + void setRespawnTime(int time); /** * * @return Respawn: 0 - Yes (Always), 1 - Day, 2 - Night, 3 - No (Dies permanently) */ - public int getRespawnCycle(); + int getRespawnCycle(); /** * * @param cycle Sets when the NPC respawns. Respawn: 0 - Yes (Always), 1 - Day, 2 - Night, 3 - No (Dies permanently) */ - public void setRespawnCycle(int cycle); + void setRespawnCycle(int cycle); /** * * @return Whether the NPC is hidden when it dies */ - public boolean getHideKilledBody(); + boolean getHideKilledBody(); /** * * @param hide True if the NPC is hidden when it dies. False otherwise. */ - public void hideKilledBody(boolean hide); + void hideKilledBody(boolean hide); /** * * @return Returns true if the NPC naturally despawns. */ - public boolean naturallyDespawns(); + boolean naturallyDespawns(); /** * * @param canDespawn True if the NPC should naturally despawn. False otherwise. */ - public void setNaturallyDespawns(boolean canDespawn); + void setNaturallyDespawns(boolean canDespawn); /** * @param player The player to give the item to * @param item The item given to the player */ - public void giveItem(ScriptPlayer player, ScriptItemStack item); + void giveItem(ScriptPlayer player, ScriptItemStack item); /** * On servers the enable-command-block option in the server.properties needs to be set to true * @param command The command to be executed */ - public void executeCommand(String command); + void executeCommand(String command); - public void setHeadScale(float x, float y, float z); + void setHeadScale(float x, float y, float z); - public void setBodyScale(float x, float y, float z); + void setBodyScale(float x, float y, float z); - public void setArmsScale(float x, float y, float z); + void setArmsScale(float x, float y, float z); - public void setLegsScale(float x, float y, float z); + void setLegsScale(float x, float y, float z); /** * @since 1.7.10c * @param resistance Explosion resistance (0-2) default is 1 */ - public void setExplosionResistance(float resistance); + void setExplosionResistance(float resistance); /** * @since 1.7.10c * @return Returns Explosion Resistance */ - public float getExplosionResistance(); + float getExplosionResistance(); /** * @param resistance Melee resistance (0-2) default is 1 */ - public void setMeleeResistance(float resistance); + void setMeleeResistance(float resistance); /** * @return Returns Melee Resistance */ - public float getMeleeResistance(); + float getMeleeResistance(); /** * @param resistance Arrow resistance (0-2) default is 1 */ - public void setArrowResistance(float resistance); + void setArrowResistance(float resistance); /** * @return Returns Arrow Resistance */ - public float getArrowResistance(); + float getArrowResistance(); /** * @param resistance Knockback resistance (0-2) default is 1 */ - public void setKnockbackResistance(float resistance); + void setKnockbackResistance(float resistance); /** * @return Returns Knockback Resistance */ - public float getKnockbackResistance(); + float getKnockbackResistance(); /** * @param type Retaliation type. 0:normal, 1:panic, 2:retreat, 3:nothing */ - public void setRetaliateType(int type); + void setRetaliateType(int type); /** * @return Returns the combat health regen per second */ - public float getCombatRegen(); + float getCombatRegen(); /** * @param regen The combat health regen per second */ - public void setCombatRegen(float regen); + void setCombatRegen(float regen); /** * @return Returns the health regen per second when not in combat */ - public float getHealthRegen(); + float getHealthRegen(); /** * @param regen The health regen per second when not in combat */ - public void setHealthRegen(float regen); + void setHealthRegen(float regen); - public long getAge(); + long getAge(); - public void setFly(int fly); + ITimers getTimers(); - public boolean canFly(); + void setFly(int fly); - public void setFlySpeed(double flySpeed); + boolean canFly(); - public double getFlySpeed(double flySpeed); + void setFlySpeed(double flySpeed); - public void setFlyGravity(double flyGravity); + double getFlySpeed(double flySpeed); - public double getFlyGravity(double flyGravity); + void setFlyGravity(double flyGravity); - public void setSpeed(int speed); + double getFlyGravity(double flyGravity); - public int getSpeed(); + void setSpeed(int speed); - public void setSkinType(byte type); + int getSpeed(); - public byte getSkinType(); + void setSkinType(byte type); - public void setSkinUrl(String url); + byte getSkinType(); - public String getSkinUrl(); + void setSkinUrl(String url); - public void setCloakTexture(String cloakTexture); + String getSkinUrl(); - public String getCloakTexture(); + void setCloakTexture(String cloakTexture); - public void setOverlayTexture(String overlayTexture); + String getCloakTexture(); - public String getOverlayTexture(); + void setOverlayTexture(String overlayTexture); - public void setCollisionType(int type); + String getOverlayTexture(); - public int getCollisionType(); + void setCollisionType(int type); - public void updateClient(); + int getCollisionType(); + + void updateClient(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ICustomOverlay.java b/src/main/java/noppes/npcs/scripted/interfaces/ICustomOverlay.java index d95a12598..05d0cf04f 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ICustomOverlay.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ICustomOverlay.java @@ -1,4 +1,38 @@ package noppes.npcs.scripted.interfaces; +import net.minecraft.nbt.NBTTagCompound; +import java.util.List; + public interface ICustomOverlay { + int getID(); + + List getComponents(); + + int getDefaultAlignment(); + + void setDefaultAlignment(int defaultAlignment); + + IOverlayTexturedRect addTexturedRect(int id, String texture, int x, int y, int width, int height); + + IOverlayTexturedRect addTexturedRect(int id, String texture, int x, int y, int width, int height, int textureX, int textureY); + + IOverlayLabel addLabel(int id, String label, int x, int y, int width, int height); + + IOverlayLabel addLabel(int id, String label, int x, int y, int width, int height, int color); + + IOverlayLine addLine(int id, int x1, int y1, int x2, int y2, int color, int thickness); + + IOverlayLine addLine(int id, int x1, int y1, int x2, int y2); + + ICustomOverlayComponent getComponent(int componentID); + + void removeComponent(int componentID); + + void updateComponent(ICustomOverlayComponent component); + + void update(IPlayer player); + + ICustomOverlay fromNBT(NBTTagCompound tag); + + NBTTagCompound toNBT(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ICustomOverlayComponent.java b/src/main/java/noppes/npcs/scripted/interfaces/ICustomOverlayComponent.java index 7abb2155d..1fe1a2cdd 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ICustomOverlayComponent.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ICustomOverlayComponent.java @@ -1,5 +1,8 @@ package noppes.npcs.scripted.interfaces; +import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.scripted.overlay.ScriptOverlayComponent; + public interface ICustomOverlayComponent { int getID(); @@ -26,4 +29,8 @@ public interface ICustomOverlayComponent { float getRotation(); void setRotation(float rotation); + + NBTTagCompound toNBT(NBTTagCompound nbt); + + ScriptOverlayComponent fromNBT(NBTTagCompound nbt); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java b/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java index 8d7dd5caa..8008559d4 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java @@ -10,6 +10,8 @@ import net.minecraft.util.DamageSource; public interface IDamageSource { String getType(); + boolean isUnblockable(); + boolean isProjectile(); IEntity getTrueSource(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java b/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java index 59e3e19af..8e9708095 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java @@ -6,274 +6,344 @@ package noppes.npcs.scripted.interfaces; import net.minecraft.entity.Entity; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.math.BlockPos; +import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.ScriptBlockPos; +import noppes.npcs.scripted.ScriptParticle; +import noppes.npcs.scripted.ScriptWorld; import noppes.npcs.scripted.entity.ScriptEntity; import noppes.npcs.scripted.item.ScriptItemStack; public interface IEntity { - public double getYOffset(); + + void spawnParticle(ScriptParticle entityParticle); + + int getEntityId(); + + String getUniqueID(); + + double getYOffset(); /** * @return The entities width */ - public double getWidth(); + double getWidth(); /** * @return The entities height */ - public double getHeight(); + double getHeight(); /** * @return The entities x position */ - public double getX(); + double getX(); /** * @param x The entities x position */ - public void setX(double x); + void setX(double x); /** * @return The entities y position */ - public double getY(); + double getY(); /** * @param y The entities y position */ - public void setY(double y); + void setY(double y); /** * @return The entities x position */ - public double getZ(); + double getZ(); /** * @param z The entities x position */ - public void setZ(double z); + void setZ(double z); + /** + * @return The entities z motion + */ + double getMotionX(); + + /** + * @param x The entities x motion + */ + void setMotionX(double x); + + /** + * @return The entities x motion + */ + double getMotionY(); + + /** + * @param y The entities y motion + */ + void setMotionY(double y); + + /** + * @return The entities y motion + */ + double getMotionZ(); + + /** + * @param z The entities z motion + */ + void setMotionZ(double z); + + void setMotion(double x, double y, double z); + + boolean isAirborne(); + /** * @return The block x position */ - public int getBlockX(); + int getBlockX(); /** * @return The block y position */ - public int getBlockY(); + int getBlockY(); /** * @return The block z position */ - public int getBlockZ(); + int getBlockZ(); /** * @param x The x position * @param y The y position * @param z The z position */ - public void setPosition(double x, double y, double z); + void setPosition(double x, double y, double z); + IPos getPos(); + + void setPos(IPos pos); + + int getDimension(); /** * @param range The search range for entities around this entity * @return Array of entities within range */ - public ScriptEntity[] getSurroundingEntities(int range); + ScriptEntity[] getSurroundingEntities(int range); /** * @param range The search range for entities around this entity * @param type The EntityType you want to find * @return Array of entities within range */ - public ScriptEntity[] getSurroundingEntities(int range, int type); + ScriptEntity[] getSurroundingEntities(int range, int type); /** * @return Whether the entity is alive or not */ - public boolean isAlive(); + boolean isAlive(); /** * @param key Get temp data for this key * @return Returns the stored temp data */ - public Object getTempData(String key); + Object getTempData(String key); /** * Tempdata gets cleared when the entity gets unloaded or the world restarts * @param key The key for the data stored * @param value The data stored */ - public void setTempData(String key, Object value); + void setTempData(String key, Object value); /** * @param key The key thats going to be tested against the temp data * @return Whether or not temp data containes the key */ - public boolean hasTempData(String key); + boolean hasTempData(String key); /** * @param key The key for the temp data to be removed */ - public void removeTempData(String key); + void removeTempData(String key); /** * Remove all tempdata */ - public void clearTempData(); + void clearTempData(); /** * @param key The key of the data to be returned * @return Returns the stored data */ - public Object getStoredData(String key); + Object getStoredData(String key); /** * Stored data persists through world restart. Unlike tempdata only Strings and Numbers can be saved * @param key The key for the data stored * @param value The data stored. This data can be either a Number or a String. Other data is not stored */ - public void setStoredData(String key, Object value); + void setStoredData(String key, Object value); /** * @param key The key of the data to be checked * @return Returns whether or not the stored data contains the key */ - public boolean hasStoredData(String key); + boolean hasStoredData(String key); /** * @param key The key of the data to be removed */ - public void removeStoredData(String key); + void removeStoredData(String key); /** * Remove all stored data */ - public void clearStoredData(); + void clearStoredData(); /** * @return The age of this entity in ticks */ - public long getAge(); + long getAge(); /** * Despawns this entity. Removes it permanently */ - public void despawn(); + void despawn(); /** * @return Return whether or not this entity is standing in water */ - public boolean inWater(); + boolean inWater(); /** * @return Return whether or not this entity is standing in lava */ - public boolean inLava(); + boolean inLava(); /** * @return Return whether or not this entity is standing in fire */ - public boolean inFire(); + boolean inFire(); /** * @return Return whether or not this entity is on fire */ - public boolean isBurning(); + boolean isBurning(); /** * @param ticks Amount of world ticks this entity will burn. 20 ticks equals 1 second */ - public void setBurning(int ticks); + void setBurning(int ticks); /** * Removes fire from this entity */ - public void extinguish(); + void extinguish(); /** * @return Name as which it's registered in minecraft */ - public String getTypeName(); + String getTypeName(); /** * @param item Item to be dropped */ - public void dropItem(ScriptItemStack item); + void dropItem(ScriptItemStack item); /** * @return Return the rider */ - public ScriptEntity getRider(); + ScriptEntity getRider(); /** * @param entity The entity to ride this entity */ - public void setRider(ScriptEntity entity); + void setRider(ScriptEntity entity); /** * @return Return the entity, this entity is riding */ - public ScriptEntity getMount(); + ScriptEntity getMount(); /** * @param entity The entity this entity will mount */ - public void setMount(ScriptEntity entity); + void setMount(ScriptEntity entity); /** * @see noppes.npcs.scripted.constants.EntityType * @return Returns the EntityType of this entity */ - public int getType(); + int getType(); /** * @since 1.7.10c * @param type @EntityType to check * @return Returns whether the entity is type of the given @EntityType */ - public boolean typeOf(int type); + boolean typeOf(int type); /** * @param rotation The rotation to be set (0-360) */ - public void setRotation(float rotation); + void setRotation(float rotation); /** * @return Current rotation of the npc */ - public float getRotation(); + float getRotation(); + + public void setPitch(float pitch); + + public float getPitch(); /** * @param power How strong the knockback is * @param direction The direction in which he flies back (0-360). Usually based on getRotation() */ - public void knockback(int power, float direction); + void knockback(int power, float direction); - public void knockback(int xpower, int ypower, int zpower, float direction); + void knockback(int xpower, int ypower, int zpower, float direction); - public void setImmune(int ticks); + void setImmune(int ticks); - public boolean hasCollided(); + public void setInvisible(boolean invisible); + + public void setSneaking(boolean sneaking); + + public void setSprinting(boolean sprinting); + + boolean hasCollided(); /** * @since 1.7.10c * @return Returns whether or not this entity is sneaking */ - public boolean isSneaking(); + boolean isSneaking(); /** * @since 1.7.10c * @return Returns whether or not this entity is sprinting */ - public boolean isSprinting(); + boolean isSprinting(); /** * @since 1.7.10c * Expert users only * @return Returns minecrafts entity */ - public T getMCEntity(); + T getMCEntity(); + + public INbt getNbt(); + + public INbt getAllNbt(); + + public void setNbt(INbt nbt); void storeAsClone(int tab, String name); + + ScriptWorld getWorld(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IEntityLivingBase.java b/src/main/java/noppes/npcs/scripted/interfaces/IEntityLivingBase.java index 3bc28a79b..e9eba3c39 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IEntityLivingBase.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IEntityLivingBase.java @@ -1,60 +1,69 @@ package noppes.npcs.scripted.interfaces; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EntityDamageSource; import noppes.npcs.scripted.entity.ScriptEntity; import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.entity.ScriptLivingBase; +import noppes.npcs.scripted.wrapper.ScriptDamageSource; public interface IEntityLivingBase extends IEntity { /** * @return The entity's current health */ - public float getHealth(); + float getHealth(); /** * @param health The new health of this entity */ - public void setHealth(float health); + void setHealth(float health); + + void hurt(float damage); + + void hurt(float damage, ScriptEntity source); + + void hurt(float damage, ScriptDamageSource damageSource); /** * @return Entity's max health */ - public double getMaxHealth(); + double getMaxHealth(); /** * @return Whether or not this entity is attacking something */ - public boolean isAttacking(); + boolean isAttacking(); /** * @param living Entity which this entity will attack */ - public void setAttackTarget(ScriptLivingBase living); + void setAttackTarget(ScriptLivingBase living); /** * @return The entity which this entity is attacking */ - public ScriptLivingBase getAttackTarget(); + ScriptLivingBase getAttackTarget(); - public int getType(); + int getType(); - public boolean typeOf(int type); + boolean typeOf(int type); /** * @param entity Entity to check * @return Whether or not this entity can see the given entity */ - public boolean canSeeEntity(ScriptEntity entity); + boolean canSeeEntity(ScriptEntity entity); /** * Expert use only * @return Returns the minecraft entity object */ - public T getMCEntity(); + T getMCEntity(); /** * Makes the entity swing its hand */ - public void swingHand(); + void swingHand(); /** * Works the same as the /effect command @@ -63,40 +72,40 @@ public interface IEntityLivingBase extends IEntity extends IEntity extends IAnimal { + boolean getIsShiny(); + + void setIsShiny(boolean bo); + + int getLevel(); + + void setLevel(int level); + + /** + * @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed + */ + int getIV(int type); + + + /** + * @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed + */ + void setIV(int type, int value); + + /** + * @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed + */ + int getEV(int type); + + + /** + * @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed + */ + void setEV(int type, int value); + + /** + * @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed + */ + int getStat(int type); + + + /** + * @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed + */ + void setStat(int type, int value); + + /** + * @return type 0:Pygmy, 1:Runt, 2:Small, 3:Normal, 4:Huge, 5:Giant, 6:Enormous, 7:Ginormous, 8:Microscopic + */ + int getSize(); + + /** + * @param type 0:Pygmy, 1:Runt, 2:Small, 3:Normal, 4:Huge, 5:Giant, 6:Enormous, 7:Ginormous, 8:Microscopic + */ + void setSize(int type); + + /** + * @return 0-255 + */ + int getHapiness(); + + /** + * @param value 0-255 + */ + void setHapiness(int value); + + /** + * @return 0:Hardy, 1:Serious, 2:Docile, 3:Bashful, 4:Quirky, 5:Lonely, 6:Brave, 7:Adamant, 8:Naughty, 9:Bold, 10:Relaxed, 11:Impish, 12:Lax, 13:Timid, 14:Hasty, 15:Jolly, 16:Naive, 17:Modest, 18:Mild, 19:Quiet, 20:Rash, 21:Calm, 22:Gentle, 23:Sassy, 24:Careful + */ + int getNature(); + + /** + * @param type 0:Hardy, 1:Serious, 2:Docile, 3:Bashful, 4:Quirky, 5:Lonely, 6:Brave, 7:Adamant, 8:Naughty, 9:Bold, 10:Relaxed, 11:Impish, 12:Lax, 13:Timid, 14:Hasty, 15:Jolly, 16:Naive, 17:Modest, 18:Mild, 19:Quiet, 20:Rash, 21:Calm, 22:Gentle, 23:Sassy, 24:Careful + */ + void setNature(int type); + + /** + * @return -1:Uncaught, 0:Pokeball, 1:GreatBall, 2:UltraBall, 3:MasterBall, 4:LevelBall, 5:MoonBall, 6:FriendBall, 7:LoveBall, 8:SafariBall, 9:HeavyBall, 10:FastBall, 11:RepeatBall, 12:TimerBall, 13:NestBall, 14:NetBall, 15:DiveBall, 16:LuxuryBall, 17:HealBall, 18:DuskBall, 19:PremierBall, 20:SportBall, 21:QuickBall, 22:ParkBall, 23:LureBall, 24:CherishBall, 25:GSBall + */ + int getPokeball(); + + /** + * @param type -1:Uncaught, 0:Pokeball, 1:GreatBall, 2:UltraBall, 3:MasterBall, 4:LevelBall, 5:MoonBall, 6:FriendBall, 7:LoveBall, 8:SafariBall, 9:HeavyBall, 10:FastBall, 11:RepeatBall, 12:TimerBall, 13:NestBall, 14:NetBall, 15:DiveBall, 16:LuxuryBall, 17:HealBall, 18:DuskBall, 19:PremierBall, 20:SportBall, 21:QuickBall, 22:ParkBall, 23:LureBall, 24:CherishBall, 25:GSBall + */ + void setPokeball(int type); + + String getNickname(); + + boolean hasNickname(); + + void setNickname(String name); + + String getMove(int slot); + + void setMove(int slot, String move); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IPlayer.java b/src/main/java/noppes/npcs/scripted/interfaces/IPlayer.java index a9f150872..18d6cf552 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IPlayer.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IPlayer.java @@ -1,103 +1,131 @@ package noppes.npcs.scripted.interfaces; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.Server; +import noppes.npcs.constants.EnumPacketClient; +import noppes.npcs.containers.ContainerCustomGui; +import noppes.npcs.controllers.*; +import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.ScriptBlock; +import noppes.npcs.scripted.entity.ScriptDBCPlayer; +import noppes.npcs.scripted.entity.ScriptEntity; +import noppes.npcs.scripted.gui.ScriptGui; +import noppes.npcs.scripted.handler.data.IQuest; import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.ScriptPixelmonPlayerData; +import noppes.npcs.scripted.overlay.ScriptOverlay; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Set; public interface IPlayer extends IEntityLivingBase { /** * @return Returns the displayed name of the player */ - public String getDisplayName(); + String getDisplayName(); /** * @return Returns the players name */ - public String getName(); + String getName(); - public void setPosition(double x, double y, double z); + void setPosition(double x, double y, double z); - public void setPosition(double x, double y, double z, int dimensionId); + void setPosition(double x, double y, double z, int dimensionId); - public boolean hasFinishedQuest(int id); + int getHunger(); - public boolean hasActiveQuest(int id); + void setHunger(int hunger); - public void showDialog(int id); + float getSaturation(); - public boolean hasReadDialog(int id); + void setSaturation(float saturation); + + int getDimension(); + + boolean hasFinishedQuest(int id); + + boolean hasActiveQuest(int id); + + void showDialog(int id); + + boolean hasReadDialog(int id); /** * Add the quest from active quest list * @param id The Quest ID */ - public void startQuest(int id); + void startQuest(int id); /** * Add the quest from finished quest list * @param id The Quest ID */ - public void finishQuest(int id); + void finishQuest(int id); /** * Removes the quest from active quest list * @param id The Quest ID */ - public void stopQuest(int id); + void stopQuest(int id); /** * Removes the quest from active and finished quest list * @param id The Quest ID */ - public void removeQuest(int id); + void removeQuest(int id); - public int getType(); + int getType(); - public boolean typeOf(int type); + boolean typeOf(int type); /** * @param faction The faction id * @param points The points to increase. Use negative values to decrease */ - public void addFactionPoints(int faction, int points); + void addFactionPoints(int faction, int points); /** * @param faction The faction id * @return points */ - public int getFactionPoints(int faction); + int getFactionPoints(int faction); /** * @param message The message you want to send */ - public void sendMessage(String message); + void sendMessage(String message); /** * @return Return gamemode. 0: Survival, 1: Creative, 2: Adventure */ - public int getMode(); + int getMode(); /** * @param type The gamemode type. 0:SURVIVAL, 1:CREATIVE, 2:ADVENTURE */ - public void setMode(int type); + void setMode(int type); /** * @param item The item to be checked * @return How many of this item the player has */ - public int inventoryItemCount(ScriptItemStack item); + int inventoryItemCount(ScriptItemStack item); /** * @since 1.7.10d * @return Returns a IItemStack array size 36 */ - public IItemStack[] getInventory(); + IItemStack[] getInventory(); /** * @param item The Item type to be removed * @param amount How many will be removed * @return Returns true if the items were removed succesfully. Returns false incase a bigger amount than what the player has was given */ - public boolean removeItem(ScriptItemStack item, int amount); + boolean removeItem(ScriptItemStack item, int amount); /** * @since 1.7.10c @@ -106,7 +134,7 @@ public interface IPlayer extends IEntityLivingBase * @param amount How many will be removed * @return Returns true if the items were removed succesfully. Returns false incase a bigger amount than what the player has was given or item doesnt exist */ - public boolean removeItem(String id, int damage, int amount); + boolean removeItem(String id, int damage, int amount); /** * @since 1.7.10c @@ -114,7 +142,7 @@ public interface IPlayer extends IEntityLivingBase * @param amount The amount of the item to be added * @return Returns whether or not it gave the item succesfully */ - public boolean giveItem(ScriptItemStack item, int amount); + boolean giveItem(ScriptItemStack item, int amount); /** * @since 1.7.10c @@ -123,7 +151,7 @@ public interface IPlayer extends IEntityLivingBase * @param amount The amount of the item to be added * @return Returns whether or not it gave the item succesfully */ - public boolean giveItem(String id, int damage, int amount); + boolean giveItem(String id, int damage, int amount); /** * Same as the /spawnpoint command @@ -131,49 +159,82 @@ public interface IPlayer extends IEntityLivingBase * @param y The y position * @param z The z position */ - public void setSpawnpoint(int x, int y, int z); + void setSpawnpoint(int x, int y, int z); - public void resetSpawnpoint(); + void resetSpawnpoint(); /** * @param item The item to be removed from the players inventory */ - public void removeAllItems(ScriptItemStack item); + void removeAllItems(ScriptItemStack item); + void setRotation(float rotationYaw, float rotationPitch); + + void stopUsingItem(); + + void clearItemInUse(); + + void playSound(String name, float volume, float pitch); + + void mountEntity(Entity ridingEntity); + + ScriptEntity dropOneItem(boolean dropStack); + + boolean canHarvestBlock(ScriptBlock block); + + boolean interactWith(ScriptEntity entity); /** * @param achievement The achievement id. For a complete list see http://minecraft.gamepedia.com/Achievements * @return Returns whether or not the player has this achievement */ - public boolean hasAchievement(String achievement); + boolean hasAchievement(String achievement); /** * @param permission Bukkit/Cauldron permission * @return Returns whether or not the player has the permission */ - public boolean hasBukkitPermission(String permission); + boolean hasBukkitPermission(String permission); /** * @since 1.7.10c * @return Returns the exp level */ - public int getExpLevel(); + int getExpLevel(); /** * @since 1.7.10c * @param level The new exp level you want to set */ - public void setExpLevel(int level); + void setExpLevel(int level); /** * Requires pixelmon to be installed * @since 1.7.10d */ - public ScriptPixelmonPlayerData getPixelmonData(); + ScriptPixelmonPlayerData getPixelmonData(); - public ITimers getTimers(); + ITimers getTimers(); - public void updatePlayerInventory(); + void updatePlayerInventory(); - public boolean checkGUIOpen(); + ScriptDBCPlayer getDBCPlayer(); + + boolean blocking(); + + IQuest[] getActiveQuests(); + + IContainer getOpenContainer(); + + void showCustomGui(ICustomGui gui); + + ICustomGui getCustomGui(); + + void closeGui(); + + void showCustomOverlay(ICustomOverlay overlay); + + void closeOverlay(int id); + + IQuest[] getFinishedQuests(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java index b3e2848e7..2366be675 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java @@ -11,12 +11,12 @@ public interface IWorld { /** * @return The worlds time */ - public long getTime(); + long getTime(); /** * @return The total world time */ - public long getTotalTime(); + long getTotalTime(); boolean areAllPlayersAsleep(); @@ -26,65 +26,65 @@ public interface IWorld { * @param z World position z * @return The block at the given position. Returns null if there isn't a block */ - public IBlock getBlock(int x, int y, int z); + IBlock getBlock(int x, int y, int z); IBlock getTopBlock(int x, int z); - public boolean isBlockFreezable(int x, int y, int z); + boolean isBlockFreezable(int x, int y, int z); - public boolean isBlockFreezableNaturally(int x, int y, int z); + boolean isBlockFreezableNaturally(int x, int y, int z); - public boolean canBlockFreeze(int x, int y, int z, boolean adjacentToWater); + boolean canBlockFreeze(int x, int y, int z, boolean adjacentToWater); - public boolean canBlockFreezeBody(int x, int y, int z, boolean adjacentToWater); + boolean canBlockFreezeBody(int x, int y, int z, boolean adjacentToWater); - public boolean canSnowAt(int x, int y, int z, boolean checkLight); + boolean canSnowAt(int x, int y, int z, boolean checkLight); - public boolean canSnowAtBody(int x, int y, int z, boolean checkLight); + boolean canSnowAtBody(int x, int y, int z, boolean checkLight); - public int getHeightValue(int x, int z); + int getHeightValue(int x, int z); - public int getChunkHeightMapMinimum(int x, int z); + int getChunkHeightMapMinimum(int x, int z); - public int getBlockMetadata(int x, int y, int z); + int getBlockMetadata(int x, int y, int z); - public boolean setBlockMetadataWithNotify(int x, int y, int z, int metadata, int flag); + boolean setBlockMetadataWithNotify(int x, int y, int z, int metadata, int flag); - public boolean canBlockSeeTheSky(int x, int y, int z); + boolean canBlockSeeTheSky(int x, int y, int z); - public int getFullBlockLightValue(int x, int y, int z); + int getFullBlockLightValue(int x, int y, int z); - public int getBlockLightValue(int x, int y, int z); + int getBlockLightValue(int x, int y, int z); - public void playSoundAtEntity(ScriptEntity entity, String sound, float volume, float pitch); + void playSoundAtEntity(ScriptEntity entity, String sound, float volume, float pitch); - public void playSoundToNearExcept(ScriptPlayer player, String sound, float volume, float pitch); + void playSoundToNearExcept(ScriptPlayer player, String sound, float volume, float pitch); - public IEntity getEntityByID(int id); + IEntity getEntityByID(int id); - public boolean spawnEntityInWorld(ScriptEntity entity); + boolean spawnEntityInWorld(ScriptEntity entity); - public ScriptPlayer getClosestPlayerToEntity(ScriptEntity entity, double range); + ScriptPlayer getClosestPlayerToEntity(ScriptEntity entity, double range); - public ScriptPlayer getClosestPlayer(double x, double y, double z, double range); + ScriptPlayer getClosestPlayer(double x, double y, double z, double range); - public ScriptPlayer getClosestVulnerablePlayerToEntity(ScriptEntity entity, double range); + ScriptPlayer getClosestVulnerablePlayerToEntity(ScriptEntity entity, double range); - public ScriptPlayer getClosestVulnerablePlayer(double x, double y, double z, double range); + ScriptPlayer getClosestVulnerablePlayer(double x, double y, double z, double range); - public int countEntities(ScriptEntity entity); + int countEntities(ScriptEntity entity); - public void setTileEntity(int x, int y, int z, ScriptTileEntity tileEntity); + void setTileEntity(int x, int y, int z, ScriptTileEntity tileEntity); - public void removeTileEntity(int x, int y, int z); + void removeTileEntity(int x, int y, int z); - public boolean isBlockFullCube(int x, int y, int z); + boolean isBlockFullCube(int x, int y, int z); - public long getSeed(); + long getSeed(); - public void setSpawnLocation(int x, int y, int z); + void setSpawnLocation(int x, int y, int z); - public boolean canLightningStrikeAt(int x, int y, int z); + boolean canLightningStrikeAt(int x, int y, int z); boolean isBlockHighHumidity(int x, int y, int z); @@ -95,7 +95,7 @@ public interface IWorld { * @return Text from signs * @since 1.7.10d */ - public String getSignText(int x, int y, int z); + String getSignText(int x, int y, int z); /** * @param x World position x @@ -103,49 +103,49 @@ public interface IWorld { * @param z World position z * @param item The block to be set */ - public void setBlock(int x, int y, int z, ScriptItemStack item); + void setBlock(int x, int y, int z, ScriptItemStack item); /** * @param x World position x * @param y World position y * @param z World position z */ - public void removeBlock(int x, int y, int z); + void removeBlock(int x, int y, int z); /** * @param name The name of the player to be returned * @return The Player with name. Null is returned when the player isnt found */ - public ScriptPlayer getPlayer(String name); + ScriptPlayer getPlayer(String name); ScriptPlayer getPlayerByUUID(String uuid); /** * @param time The world time to be set */ - public void setTime(long time); + void setTime(long time); /** * @return Whether or not its daytime */ - public boolean isDay(); + boolean isDay(); /** * @return Whether or not its currently raining */ - public boolean isRaining(); + boolean isRaining(); /** * @param bo Set if it's raining */ - public void setRaining(boolean bo); + void setRaining(boolean bo); /** * @param x The x position * @param y The y position * @param z The z position */ - public void thunderStrike(double x, double y, double z); + void thunderStrike(double x, double y, double z); /** * Sends a packet from the server to the client everytime its called. Probably should not use this too much. @@ -159,7 +159,7 @@ public interface IWorld { * @param speed Speed of the particles, usually between 0 and 1 * @param count Particle count */ - public void spawnParticle(String particle, double x, double y, double z, double dx, double dy, double dz, double speed, int count); + void spawnParticle(String particle, double x, double y, double z, double dx, double dy, double dz, double speed, int count); /** * @param id The items name @@ -167,71 +167,71 @@ public interface IWorld { * @param size The number of items in the item * @return Returns the item */ - public IItemStack createItem(String id, int damage, int size); + IItemStack createItem(String id, int damage, int size); /** * @param directory The particle's texture directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/tail.png" * @return Returns ScriptEntityParticle object */ - public ScriptParticle createEntityParticle(String directory); + ScriptParticle createEntityParticle(String directory); /** * @param key Get temp data for this key * @return Returns the stored temp data */ - public Object getTempData(String key); + Object getTempData(String key); /** * Tempdata gets cleared when the server restarts. All worlds share the same temp data. * @param key The key for the data stored * @param value The data stored */ - public void setTempData(String key, Object value); + void setTempData(String key, Object value); /** * @param key The key thats going to be tested against the temp data * @return Whether or not temp data containes the key */ - public boolean hasTempData(String key); + boolean hasTempData(String key); /** * @param key The key for the temp data to be removed */ - public void removeTempData(String key); + void removeTempData(String key); /** * Removes all tempdata */ - public void clearTempData(); + void clearTempData(); /** * @param key The key of the data to be returned * @return Returns the stored data */ - public Object getStoredData(String key); + Object getStoredData(String key); /** * Stored data persists through world restart. Unlike tempdata only Strings and Numbers can be saved * @param key The key for the data stored * @param value The data stored. This data can be either a Number or a String. Other data is not stored */ - public void setStoredData(String key, Object value); + void setStoredData(String key, Object value); /** * @param key The key of the data to be checked * @return Returns whether or not the stored data contains the key */ - public boolean hasStoredData(String key); + boolean hasStoredData(String key); /** * @param key The key of the data to be removed */ - public void removeStoredData(String key); + void removeStoredData(String key); /** * Remove all stored data */ - public void clearStoredData(); + void clearStoredData(); /** * @param x Position x @@ -241,9 +241,9 @@ public interface IWorld { * @param fire Whether or not the explosion does fire damage * @param grief Whether or not the explosion does damage to blocks */ - public void explode(double x, double y, double z, float range, boolean fire, boolean grief); + void explode(double x, double y, double z, float range, boolean fire, boolean grief); - public ScriptPlayer[] getAllServerPlayers(); + ScriptPlayer[] getAllServerPlayers(); /** * @since 1.7.10c @@ -251,7 +251,7 @@ public interface IWorld { * @param z Position z * @return Returns the name of the biome */ - public String getBiomeName(int x, int z); + String getBiomeName(int x, int z); /** * Lets you spawn a server side cloned entity @@ -262,9 +262,9 @@ public interface IWorld { * @param name Name of the cloned entity * @return Returns the entity which was spawned */ - public ScriptEntity spawnClone(int x, int y, int z, int tab, String name); + ScriptEntity spawnClone(int x, int y, int z, int tab, String name); - public ScriptScoreboard getScoreboard(); + ScriptScoreboard getScoreboard(); BlockPos getMCBlockPos(int x, int y, int z); @@ -273,7 +273,7 @@ public interface IWorld { * Expert use only * @return Returns minecraft world object */ - public WorldServer getMCWorld(); + WorldServer getMCWorld(); - public int getDimensionID(); + int getDimensionID(); } diff --git a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java index a3394a7eb..58eb082d3 100644 --- a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java +++ b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java @@ -37,10 +37,6 @@ public class ScriptOverlay implements ICustomOverlay { return this.components; } - public PlayerDataScript getScriptHandler() { - return ScriptController.Instance.playerScripts;//this.scriptHandler; - } - public int getDefaultAlignment(){ return this.defaultAlignment; } From 6dea5a1cbc64440c55dd7c87c14542d3b5da9261 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 11 May 2022 16:43:14 -0500 Subject: [PATCH 30/75] Interfaces have a file strucutre resembling the file structure of their implementing classes. --- src/main/java/noppes/npcs/DataScript.java | 3 +- src/main/java/noppes/npcs/EventHooks.java | 6 +- .../java/noppes/npcs/NoppesUtilPlayer.java | 3 +- .../noppes/npcs/ScriptItemEventHandler.java | 6 +- .../npcs/client/gui/custom/GuiCustom.java | 3 +- .../custom/components/CustomGuiButton.java | 3 +- .../gui/custom/components/CustomGuiLabel.java | 2 +- .../gui/custom/components/CustomGuiLine.java | 5 +- .../components/CustomGuiScrollComponent.java | 2 +- .../custom/components/CustomGuiTextField.java | 4 +- .../components/CustomGuiTexturedRect.java | 6 +- .../gui/custom/interfaces/IGuiComponent.java | 2 +- .../gui/customoverlay/OverlayCustom.java | 3 +- .../components/CustomOverlayLabel.java | 2 +- .../components/CustomOverlayLine.java | 6 +- .../components/CustomOverlayTexturedRect.java | 7 +- .../npcs/containers/ContainerCustomGui.java | 2 +- .../noppes/npcs/controllers/Availability.java | 4 +- .../npcs/controllers/CustomGuiController.java | 2 +- .../java/noppes/npcs/controllers/Dialog.java | 2 +- .../npcs/controllers/DialogCategory.java | 4 +- .../npcs/controllers/DialogController.java | 6 +- .../java/noppes/npcs/controllers/Faction.java | 6 +- .../npcs/controllers/FactionController.java | 6 +- .../java/noppes/npcs/controllers/Quest.java | 10 +- .../npcs/controllers/QuestCategory.java | 4 +- .../npcs/controllers/QuestController.java | 6 +- .../npcs/controllers/RecipeCarpentry.java | 5 +- .../npcs/controllers/RecipeController.java | 4 +- .../controllers/ServerCloneController.java | 12 +- .../npcs/controllers/data/NPCDataScript.java | 3 +- .../controllers/data/PlayerDataScript.java | 11 +- .../npcs/entity/EntityNPCInterface.java | 3 +- .../java/noppes/npcs/items/ItemScripted.java | 4 +- .../java/noppes/npcs/quests/QuestDialog.java | 4 +- .../noppes/npcs/quests/QuestInterface.java | 4 +- .../java/noppes/npcs/quests/QuestItem.java | 4 +- .../java/noppes/npcs/quests/QuestKill.java | 7 +- .../noppes/npcs/quests/QuestLocation.java | 4 +- .../java/noppes/npcs/scripted/NpcAPI.java | 4 +- .../noppes/npcs/scripted/ScriptContainer.java | 2 +- .../noppes/npcs/scripted/ScriptParticle.java | 93 ++++++------ .../noppes/npcs/scripted/ScriptWorld.java | 8 +- .../npcs/scripted/entity/ScriptAnimal.java | 2 +- .../npcs/scripted/entity/ScriptDBCPlayer.java | 2 +- .../npcs/scripted/entity/ScriptEntity.java | 2 +- .../npcs/scripted/entity/ScriptLiving.java | 2 +- .../scripted/entity/ScriptLivingBase.java | 5 +- .../npcs/scripted/entity/ScriptMonster.java | 2 +- .../npcs/scripted/entity/ScriptNpc.java | 5 +- .../npcs/scripted/entity/ScriptPixelmon.java | 2 +- .../npcs/scripted/entity/ScriptPlayer.java | 6 +- .../npcs/scripted/event/CustomGuiEvent.java | 6 +- .../npcs/scripted/event/DialogEvent.java | 4 +- .../npcs/scripted/event/FactionEvent.java | 4 +- .../npcs/scripted/event/ForgeEvent.java | 2 +- .../noppes/npcs/scripted/event/ItemEvent.java | 10 +- .../noppes/npcs/scripted/event/NpcEvent.java | 5 + .../npcs/scripted/event/PlayerEvent.java | 4 + .../npcs/scripted/event/QuestEvent.java | 6 +- .../scripted/event/ScriptEventDialog.java | 3 +- .../noppes/npcs/scripted/gui/ScriptGui.java | 7 +- .../npcs/scripted/gui/ScriptGuiButton.java | 4 +- .../npcs/scripted/gui/ScriptGuiComponent.java | 3 +- .../npcs/scripted/gui/ScriptGuiItemSlot.java | 4 +- .../npcs/scripted/gui/ScriptGuiLabel.java | 2 +- .../npcs/scripted/gui/ScriptGuiLine.java | 2 +- .../npcs/scripted/gui/ScriptGuiScroll.java | 2 +- .../npcs/scripted/gui/ScriptGuiTextField.java | 2 +- .../scripted/gui/ScriptGuiTexturedRect.java | 2 +- .../handler/data/IQuestInterface.java | 4 - .../npcs/scripted/interfaces/IContainer.java | 1 + .../scripted/interfaces/IDamageSource.java | 1 + .../npcs/scripted/interfaces/IParticle.java | 134 ++++++++++++++++++ .../npcs/scripted/interfaces/IWorld.java | 2 + .../interfaces/{ => entity}/IAnimal.java | 2 +- .../interfaces/{ => entity}/ICustomNpc.java | 4 +- .../interfaces/{ => entity}/IEntity.java | 4 +- .../{ => entity}/IEntityLiving.java | 2 +- .../{ => entity}/IEntityLivingBase.java | 5 +- .../interfaces/{ => entity}/IMonster.java | 2 +- .../interfaces/{ => entity}/IPixelmon.java | 4 +- .../interfaces/{ => entity}/IPlayer.java | 21 +-- .../interfaces/{ => gui}/IButton.java | 2 +- .../interfaces/{ => gui}/ICustomGui.java | 4 +- .../{ => gui}/ICustomGuiComponent.java | 2 +- .../interfaces/{ => gui}/IItemSlot.java | 3 +- .../scripted/interfaces/{ => gui}/ILabel.java | 2 +- .../scripted/interfaces/{ => gui}/ILine.java | 2 +- .../interfaces/{ => gui}/IScroll.java | 2 +- .../interfaces/{ => gui}/ITextField.java | 2 +- .../interfaces/{ => gui}/ITexturedRect.java | 2 +- .../handler/ICloneHandler.java | 4 +- .../handler/IDialogHandler.java | 6 +- .../handler/IFactionHandler.java | 4 +- .../handler/IQuestHandler.java | 6 +- .../handler/IRecipeHandler.java | 4 +- .../handler/data/IAvailability.java | 4 +- .../handler/data/IDialog.java | 2 +- .../handler/data/IDialogCategory.java | 2 +- .../handler/data/IDialogOption.java | 2 +- .../handler/data/IFaction.java | 6 +- .../{ => interfaces}/handler/data/IQuest.java | 4 +- .../handler/data/IQuestCategory.java | 2 +- .../handler/data/IQuestDialog.java | 2 +- .../handler/data/IQuestInterface.java | 4 + .../handler/data/IQuestItem.java | 2 +- .../handler/data/IQuestKill.java | 2 +- .../handler/data/IQuestLocation.java | 2 +- .../handler/data/IQuestObjective.java | 2 +- .../handler/data/IRecipe.java | 2 +- .../interfaces/{ => item}/ICustomItem.java | 4 +- .../interfaces/{ => item}/IItemStack.java | 3 +- .../{ => overlay}/ICustomOverlay.java | 4 +- .../ICustomOverlayComponent.java | 2 +- .../{ => overlay}/IOverlayLabel.java | 2 +- .../{ => overlay}/IOverlayLine.java | 4 +- .../{ => overlay}/IOverlayTexturedRect.java | 2 +- .../npcs/scripted/item/ScriptCustomItem.java | 2 +- .../npcs/scripted/item/ScriptItemStack.java | 2 +- .../npcs/scripted/overlay/ScriptOverlay.java | 9 +- .../overlay/ScriptOverlayComponent.java | 7 +- .../scripted/overlay/ScriptOverlayLabel.java | 4 +- .../scripted/overlay/ScriptOverlayLine.java | 3 +- .../overlay/ScriptOverlayTexturedRect.java | 5 +- .../scripted/wrapper/ScriptDamageSource.java | 3 +- .../scripted/wrapper/WrapperEntityData.java | 2 +- .../npcs/scripted/wrapper/WrapperNpcAPI.java | 8 +- 128 files changed, 401 insertions(+), 321 deletions(-) delete mode 100644 src/main/java/noppes/npcs/scripted/handler/data/IQuestInterface.java create mode 100644 src/main/java/noppes/npcs/scripted/interfaces/IParticle.java rename src/main/java/noppes/npcs/scripted/interfaces/{ => entity}/IAnimal.java (83%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => entity}/ICustomNpc.java (99%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => entity}/IEntity.java (98%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => entity}/IEntityLiving.java (89%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => entity}/IEntityLivingBase.java (95%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => entity}/IMonster.java (82%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => entity}/IPixelmon.java (96%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => entity}/IPlayer.java (91%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => gui}/IButton.java (91%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => gui}/ICustomGui.java (92%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => gui}/ICustomGuiComponent.java (94%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => gui}/IItemSlot.java (76%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => gui}/ILabel.java (90%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => gui}/ILine.java (86%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => gui}/IScroll.java (91%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => gui}/ITextField.java (87%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => gui}/ITexturedRect.java (91%) rename src/main/java/noppes/npcs/scripted/{ => interfaces}/handler/ICloneHandler.java (80%) rename src/main/java/noppes/npcs/scripted/{ => interfaces}/handler/IDialogHandler.java (56%) rename src/main/java/noppes/npcs/scripted/{ => interfaces}/handler/IFactionHandler.java (73%) rename src/main/java/noppes/npcs/scripted/{ => interfaces}/handler/IQuestHandler.java (56%) rename src/main/java/noppes/npcs/scripted/{ => interfaces}/handler/IRecipeHandler.java (81%) rename src/main/java/noppes/npcs/scripted/{ => interfaces}/handler/data/IAvailability.java (85%) rename src/main/java/noppes/npcs/scripted/{ => interfaces}/handler/data/IDialog.java (94%) rename src/main/java/noppes/npcs/scripted/{ => interfaces}/handler/data/IDialogCategory.java (81%) rename src/main/java/noppes/npcs/scripted/{ => interfaces}/handler/data/IDialogOption.java (79%) rename src/main/java/noppes/npcs/scripted/{ => interfaces}/handler/data/IFaction.java (80%) rename src/main/java/noppes/npcs/scripted/{ => interfaces}/handler/data/IQuest.java (87%) rename src/main/java/noppes/npcs/scripted/{ => interfaces}/handler/data/IQuestCategory.java (81%) rename src/main/java/noppes/npcs/scripted/{ => interfaces}/handler/data/IQuestDialog.java (52%) create mode 100644 src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestInterface.java rename src/main/java/noppes/npcs/scripted/{ => interfaces}/handler/data/IQuestItem.java (83%) rename src/main/java/noppes/npcs/scripted/{ => interfaces}/handler/data/IQuestKill.java (68%) rename src/main/java/noppes/npcs/scripted/{ => interfaces}/handler/data/IQuestLocation.java (82%) rename src/main/java/noppes/npcs/scripted/{ => interfaces}/handler/data/IQuestObjective.java (83%) rename src/main/java/noppes/npcs/scripted/{ => interfaces}/handler/data/IRecipe.java (90%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => item}/ICustomItem.java (95%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => item}/IItemStack.java (97%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => overlay}/ICustomOverlay.java (91%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => overlay}/ICustomOverlayComponent.java (93%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => overlay}/IOverlayLabel.java (87%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => overlay}/IOverlayLine.java (75%) rename src/main/java/noppes/npcs/scripted/interfaces/{ => overlay}/IOverlayTexturedRect.java (89%) diff --git a/src/main/java/noppes/npcs/DataScript.java b/src/main/java/noppes/npcs/DataScript.java index 90b435332..8e8c70cc3 100644 --- a/src/main/java/noppes/npcs/DataScript.java +++ b/src/main/java/noppes/npcs/DataScript.java @@ -14,7 +14,6 @@ import noppes.npcs.constants.EnumScriptType; import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.controllers.IScriptHandler; import noppes.npcs.controllers.ScriptController; -import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.event.ScriptEvent; @@ -23,7 +22,7 @@ import noppes.npcs.scripted.ScriptWorld; import noppes.npcs.scripted.constants.EntityType; import noppes.npcs.scripted.constants.JobType; import noppes.npcs.scripted.constants.RoleType; -import noppes.npcs.scripted.interfaces.ICustomNpc; +import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import noppes.npcs.scripted.interfaces.IWorld; import noppes.npcs.scripted.wrapper.WrapperNpcAPI; diff --git a/src/main/java/noppes/npcs/EventHooks.java b/src/main/java/noppes/npcs/EventHooks.java index d9c755ee3..407b33acb 100644 --- a/src/main/java/noppes/npcs/EventHooks.java +++ b/src/main/java/noppes/npcs/EventHooks.java @@ -7,7 +7,6 @@ package noppes.npcs; import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityXPOrb; @@ -25,7 +24,6 @@ import noppes.npcs.controllers.data.ForgeDataScript; import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.*; -import noppes.npcs.scripted.entity.ScriptEntity; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.event.*; import noppes.npcs.scripted.event.PlayerEvent.ChatEvent; @@ -37,6 +35,10 @@ import noppes.npcs.scripted.event.PlayerEvent.LogoutEvent; import noppes.npcs.scripted.event.PlayerEvent.PickUpEvent; import noppes.npcs.scripted.event.PlayerEvent.DropEvent; import noppes.npcs.scripted.interfaces.*; +import noppes.npcs.scripted.interfaces.entity.IEntity; +import noppes.npcs.scripted.interfaces.entity.IPlayer; +import noppes.npcs.scripted.interfaces.gui.ICustomGui; +import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptCustomItem; import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.wrapper.WrapperNpcAPI; diff --git a/src/main/java/noppes/npcs/NoppesUtilPlayer.java b/src/main/java/noppes/npcs/NoppesUtilPlayer.java index 47145ef70..6e5101f6e 100644 --- a/src/main/java/noppes/npcs/NoppesUtilPlayer.java +++ b/src/main/java/noppes/npcs/NoppesUtilPlayer.java @@ -22,7 +22,6 @@ import noppes.npcs.constants.EnumOptionType; import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumPlayerPacket; import noppes.npcs.constants.EnumRoleType; -import noppes.npcs.constants.EnumScriptType; import noppes.npcs.containers.ContainerNPCBankInterface; import noppes.npcs.containers.ContainerNPCFollower; import noppes.npcs.containers.ContainerNPCFollowerHire; @@ -34,7 +33,7 @@ import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.event.DialogEvent; import noppes.npcs.scripted.event.QuestEvent; -import noppes.npcs.scripted.interfaces.IItemStack; +import noppes.npcs.scripted.interfaces.item.IItemStack; public class NoppesUtilPlayer { diff --git a/src/main/java/noppes/npcs/ScriptItemEventHandler.java b/src/main/java/noppes/npcs/ScriptItemEventHandler.java index c5de605c2..23d56811a 100644 --- a/src/main/java/noppes/npcs/ScriptItemEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptItemEventHandler.java @@ -10,18 +10,16 @@ import net.minecraft.world.WorldServer; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.item.ItemTossEvent; import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.player.EntityInteractEvent; import net.minecraftforge.event.entity.player.PlayerUseItemEvent; import noppes.npcs.controllers.ScriptController; -import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.items.ItemScripted; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.event.ItemEvent; -import noppes.npcs.scripted.interfaces.IItemStack; -import noppes.npcs.scripted.interfaces.IPlayer; +import noppes.npcs.scripted.interfaces.item.IItemStack; +import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.item.ScriptCustomItem; import java.util.HashMap; diff --git a/src/main/java/noppes/npcs/client/gui/custom/GuiCustom.java b/src/main/java/noppes/npcs/client/gui/custom/GuiCustom.java index 544465490..83cda2522 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/GuiCustom.java +++ b/src/main/java/noppes/npcs/client/gui/custom/GuiCustom.java @@ -5,7 +5,6 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; -import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.texture.TextureMap; @@ -31,7 +30,7 @@ import noppes.npcs.client.gui.util.IGuiData; import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.containers.ContainerCustomGui; import noppes.npcs.scripted.gui.*; -import noppes.npcs.scripted.interfaces.ICustomGuiComponent; +import noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiButton.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiButton.java index a51ce5f45..ca93e04d0 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiButton.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiButton.java @@ -10,14 +10,13 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.renderer.texture.ITextureObject; import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.resources.SkinManager; import net.minecraft.util.ResourceLocation; import noppes.npcs.client.ImageDownloadAlt; import noppes.npcs.client.gui.custom.GuiCustom; import noppes.npcs.client.gui.custom.interfaces.IClickListener; import noppes.npcs.client.renderer.ImageBufferDownloadAlt; import noppes.npcs.scripted.gui.ScriptGuiButton; -import noppes.npcs.scripted.interfaces.ICustomGuiComponent; +import noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent; import org.lwjgl.opengl.GL11; public class CustomGuiButton extends GuiButton implements IClickListener { diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java index f98ec1411..7d99a4a87 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLabel.java @@ -15,7 +15,7 @@ import net.minecraft.util.ResourceLocation; import noppes.npcs.client.gui.custom.GuiCustom; import noppes.npcs.client.gui.custom.interfaces.IGuiComponent; import noppes.npcs.scripted.gui.ScriptGuiLabel; -import noppes.npcs.scripted.interfaces.ICustomGuiComponent; +import noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent; import org.lwjgl.opengl.GL11; import javax.imageio.ImageIO; diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLine.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLine.java index 5a1b2804e..a28fe8f4e 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLine.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiLine.java @@ -6,12 +6,9 @@ import net.minecraft.util.ResourceLocation; import noppes.npcs.client.gui.custom.GuiCustom; import noppes.npcs.client.gui.custom.interfaces.IGuiComponent; import noppes.npcs.scripted.gui.ScriptGuiLine; -import noppes.npcs.scripted.interfaces.ICustomGuiComponent; +import noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent; import org.lwjgl.opengl.GL11; -import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA; -import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA; - public class CustomGuiLine extends Gui implements IGuiComponent { int id; GuiCustom parent; diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java index 26f626ad9..c809331e8 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiScrollComponent.java @@ -17,7 +17,7 @@ import noppes.npcs.client.gui.custom.interfaces.IClickListener; import noppes.npcs.client.gui.custom.interfaces.IDataHolder; import noppes.npcs.client.gui.util.GuiCustomScroll; import noppes.npcs.scripted.gui.ScriptGuiScroll; -import noppes.npcs.scripted.interfaces.ICustomGuiComponent; +import noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent; import org.lwjgl.opengl.GL11; public class CustomGuiScrollComponent extends GuiCustomScroll implements IDataHolder, IClickListener { diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTextField.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTextField.java index 876eccd41..1d02d405e 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTextField.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTextField.java @@ -8,14 +8,12 @@ package noppes.npcs.client.gui.custom.components; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiTextField; import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.client.Client; import noppes.npcs.client.gui.custom.GuiCustom; import noppes.npcs.client.gui.custom.interfaces.IClickListener; import noppes.npcs.client.gui.custom.interfaces.IDataHolder; import noppes.npcs.client.gui.custom.interfaces.IKeyListener; -import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.scripted.gui.ScriptGuiTextField; -import noppes.npcs.scripted.interfaces.ICustomGuiComponent; +import noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent; import org.lwjgl.opengl.GL11; public class CustomGuiTextField extends GuiTextField implements IKeyListener, IDataHolder, IClickListener { diff --git a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java index 163ed6b37..e11759649 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java +++ b/src/main/java/noppes/npcs/client/gui/custom/components/CustomGuiTexturedRect.java @@ -10,19 +10,15 @@ import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.ITextureObject; import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.resources.SkinManager; import net.minecraft.util.ResourceLocation; import noppes.npcs.client.ImageDownloadAlt; import noppes.npcs.client.gui.custom.GuiCustom; import noppes.npcs.client.gui.custom.interfaces.IGuiComponent; import noppes.npcs.client.renderer.ImageBufferDownloadAlt; import noppes.npcs.scripted.gui.ScriptGuiTexturedRect; -import noppes.npcs.scripted.interfaces.ICustomGuiComponent; +import noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent; import org.lwjgl.opengl.GL11; -import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA; -import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA; - public class CustomGuiTexturedRect extends Gui implements IGuiComponent { GuiCustom parent; ResourceLocation texture; diff --git a/src/main/java/noppes/npcs/client/gui/custom/interfaces/IGuiComponent.java b/src/main/java/noppes/npcs/client/gui/custom/interfaces/IGuiComponent.java index af8f1d248..76f6c142b 100644 --- a/src/main/java/noppes/npcs/client/gui/custom/interfaces/IGuiComponent.java +++ b/src/main/java/noppes/npcs/client/gui/custom/interfaces/IGuiComponent.java @@ -6,7 +6,7 @@ package noppes.npcs.client.gui.custom.interfaces; import net.minecraft.client.Minecraft; -import noppes.npcs.scripted.interfaces.ICustomGuiComponent; +import noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent; public interface IGuiComponent { int getID(); diff --git a/src/main/java/noppes/npcs/client/gui/customoverlay/OverlayCustom.java b/src/main/java/noppes/npcs/client/gui/customoverlay/OverlayCustom.java index dea871e62..503ef6373 100644 --- a/src/main/java/noppes/npcs/client/gui/customoverlay/OverlayCustom.java +++ b/src/main/java/noppes/npcs/client/gui/customoverlay/OverlayCustom.java @@ -5,12 +5,11 @@ import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; import noppes.npcs.client.gui.customoverlay.components.CustomOverlayLabel; import noppes.npcs.client.gui.customoverlay.components.CustomOverlayLine; import noppes.npcs.client.gui.customoverlay.components.CustomOverlayTexturedRect; import noppes.npcs.client.gui.customoverlay.interfaces.IOverlayComponent; -import noppes.npcs.scripted.interfaces.ICustomOverlayComponent; +import noppes.npcs.scripted.interfaces.overlay.ICustomOverlayComponent; import noppes.npcs.scripted.overlay.*; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLabel.java b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLabel.java index ec7212a2a..3c84d6b48 100644 --- a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLabel.java +++ b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLabel.java @@ -9,7 +9,7 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.ResourceLocation; import noppes.npcs.client.gui.customoverlay.OverlayCustom; import noppes.npcs.client.gui.customoverlay.interfaces.IOverlayComponent; -import noppes.npcs.scripted.interfaces.ICustomOverlayComponent; +import noppes.npcs.scripted.interfaces.overlay.ICustomOverlayComponent; import noppes.npcs.scripted.overlay.ScriptOverlayLabel; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLine.java b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLine.java index be019ee22..4018b71b9 100644 --- a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLine.java +++ b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayLine.java @@ -2,18 +2,14 @@ package noppes.npcs.client.gui.customoverlay.components; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.ResourceLocation; import noppes.npcs.client.gui.customoverlay.OverlayCustom; import noppes.npcs.client.gui.customoverlay.interfaces.IOverlayComponent; -import noppes.npcs.scripted.interfaces.ICustomOverlayComponent; +import noppes.npcs.scripted.interfaces.overlay.ICustomOverlayComponent; import noppes.npcs.scripted.overlay.ScriptOverlayLine; import org.lwjgl.opengl.GL11; -import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA; -import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA; - public class CustomOverlayLine extends Gui implements IOverlayComponent { OverlayCustom parent; int alignment; diff --git a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayTexturedRect.java b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayTexturedRect.java index 2a6367815..b1402308f 100644 --- a/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayTexturedRect.java +++ b/src/main/java/noppes/npcs/client/gui/customoverlay/components/CustomOverlayTexturedRect.java @@ -2,23 +2,18 @@ package noppes.npcs.client.gui.customoverlay.components; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.ITextureObject; import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.resources.SkinManager; import net.minecraft.util.ResourceLocation; import noppes.npcs.client.ImageDownloadAlt; import noppes.npcs.client.gui.customoverlay.OverlayCustom; import noppes.npcs.client.gui.customoverlay.interfaces.IOverlayComponent; import noppes.npcs.client.renderer.ImageBufferDownloadAlt; -import noppes.npcs.scripted.interfaces.ICustomOverlayComponent; +import noppes.npcs.scripted.interfaces.overlay.ICustomOverlayComponent; import noppes.npcs.scripted.overlay.ScriptOverlayTexturedRect; import org.lwjgl.opengl.GL11; -import static org.lwjgl.opengl.GL11.*; -import static org.lwjgl.opengl.GL14.glBlendFuncSeparate; - public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent { OverlayCustom parent; int alignment; diff --git a/src/main/java/noppes/npcs/containers/ContainerCustomGui.java b/src/main/java/noppes/npcs/containers/ContainerCustomGui.java index c16a4cc91..a23de67b7 100644 --- a/src/main/java/noppes/npcs/containers/ContainerCustomGui.java +++ b/src/main/java/noppes/npcs/containers/ContainerCustomGui.java @@ -11,7 +11,7 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import noppes.npcs.scripted.interfaces.IItemSlot; +import noppes.npcs.scripted.interfaces.gui.IItemSlot; import noppes.npcs.scripted.gui.ScriptGui; import noppes.npcs.client.gui.custom.components.CustomGuiSlot; diff --git a/src/main/java/noppes/npcs/controllers/Availability.java b/src/main/java/noppes/npcs/controllers/Availability.java index e378717dd..f20c0ed33 100644 --- a/src/main/java/noppes/npcs/controllers/Availability.java +++ b/src/main/java/noppes/npcs/controllers/Availability.java @@ -11,8 +11,8 @@ import noppes.npcs.constants.EnumAvailabilityFactionType; import noppes.npcs.constants.EnumAvailabilityQuest; import noppes.npcs.constants.EnumDayTime; import noppes.npcs.scripted.CustomNPCsException; -import noppes.npcs.scripted.handler.data.IAvailability; -import noppes.npcs.scripted.interfaces.IPlayer; +import noppes.npcs.scripted.interfaces.handler.data.IAvailability; +import noppes.npcs.scripted.interfaces.entity.IPlayer; public class Availability implements ICompatibilty, IAvailability { public int version = VersionCompatibility.ModRev; diff --git a/src/main/java/noppes/npcs/controllers/CustomGuiController.java b/src/main/java/noppes/npcs/controllers/CustomGuiController.java index 53cbc932d..1849561e0 100644 --- a/src/main/java/noppes/npcs/controllers/CustomGuiController.java +++ b/src/main/java/noppes/npcs/controllers/CustomGuiController.java @@ -14,7 +14,7 @@ import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.event.CustomGuiEvent; import noppes.npcs.scripted.gui.ScriptGui; -import noppes.npcs.scripted.interfaces.IItemStack; +import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.overlay.ScriptOverlay; import noppes.npcs.scripted.wrapper.WrapperNpcAPI; diff --git a/src/main/java/noppes/npcs/controllers/Dialog.java b/src/main/java/noppes/npcs/controllers/Dialog.java index 1a332473e..6632f8433 100644 --- a/src/main/java/noppes/npcs/controllers/Dialog.java +++ b/src/main/java/noppes/npcs/controllers/Dialog.java @@ -11,7 +11,7 @@ import noppes.npcs.ICompatibilty; import noppes.npcs.VersionCompatibility; import noppes.npcs.constants.EnumOptionType; import noppes.npcs.scripted.CustomNPCsException; -import noppes.npcs.scripted.handler.data.*; +import noppes.npcs.scripted.interfaces.handler.data.*; public class Dialog implements ICompatibilty, IDialog { public int version = VersionCompatibility.ModRev; diff --git a/src/main/java/noppes/npcs/controllers/DialogCategory.java b/src/main/java/noppes/npcs/controllers/DialogCategory.java index d6314ad88..20c1fb0b1 100644 --- a/src/main/java/noppes/npcs/controllers/DialogCategory.java +++ b/src/main/java/noppes/npcs/controllers/DialogCategory.java @@ -6,8 +6,8 @@ import java.util.List; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import noppes.npcs.scripted.handler.data.IDialog; -import noppes.npcs.scripted.handler.data.IDialogCategory; +import noppes.npcs.scripted.interfaces.handler.data.IDialog; +import noppes.npcs.scripted.interfaces.handler.data.IDialogCategory; public class DialogCategory implements IDialogCategory { diff --git a/src/main/java/noppes/npcs/controllers/DialogController.java b/src/main/java/noppes/npcs/controllers/DialogController.java index 69156b429..9791ca720 100644 --- a/src/main/java/noppes/npcs/controllers/DialogController.java +++ b/src/main/java/noppes/npcs/controllers/DialogController.java @@ -11,9 +11,9 @@ import noppes.npcs.CustomNpcs; import noppes.npcs.LogWriter; import noppes.npcs.NoppesStringUtils; import noppes.npcs.constants.EnumOptionType; -import noppes.npcs.scripted.handler.IDialogHandler; -import noppes.npcs.scripted.handler.data.IDialog; -import noppes.npcs.scripted.handler.data.IDialogCategory; +import noppes.npcs.scripted.interfaces.handler.IDialogHandler; +import noppes.npcs.scripted.interfaces.handler.data.IDialog; +import noppes.npcs.scripted.interfaces.handler.data.IDialogCategory; import noppes.npcs.util.NBTJsonUtil; public class DialogController implements IDialogHandler { diff --git a/src/main/java/noppes/npcs/controllers/Faction.java b/src/main/java/noppes/npcs/controllers/Faction.java index 7a7ace55e..03a6a44d2 100644 --- a/src/main/java/noppes/npcs/controllers/Faction.java +++ b/src/main/java/noppes/npcs/controllers/Faction.java @@ -8,9 +8,9 @@ import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.NBTTags; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.CustomNPCsException; -import noppes.npcs.scripted.handler.data.IFaction; -import noppes.npcs.scripted.interfaces.ICustomNpc; -import noppes.npcs.scripted.interfaces.IPlayer; +import noppes.npcs.scripted.interfaces.handler.data.IFaction; +import noppes.npcs.scripted.interfaces.entity.ICustomNpc; +import noppes.npcs.scripted.interfaces.entity.IPlayer; public class Faction implements IFaction { public String name = ""; diff --git a/src/main/java/noppes/npcs/controllers/FactionController.java b/src/main/java/noppes/npcs/controllers/FactionController.java index 36b2db79c..5b59d349a 100644 --- a/src/main/java/noppes/npcs/controllers/FactionController.java +++ b/src/main/java/noppes/npcs/controllers/FactionController.java @@ -17,10 +17,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.CustomNpcs; import noppes.npcs.LogWriter; -import noppes.npcs.Server; -import noppes.npcs.constants.EnumPacketClient; -import noppes.npcs.scripted.handler.IFactionHandler; -import noppes.npcs.scripted.handler.data.IFaction; +import noppes.npcs.scripted.interfaces.handler.IFactionHandler; +import noppes.npcs.scripted.interfaces.handler.data.IFaction; public class FactionController implements IFactionHandler { public HashMap factions; diff --git a/src/main/java/noppes/npcs/controllers/Quest.java b/src/main/java/noppes/npcs/controllers/Quest.java index 3205d3073..739b32010 100644 --- a/src/main/java/noppes/npcs/controllers/Quest.java +++ b/src/main/java/noppes/npcs/controllers/Quest.java @@ -18,12 +18,12 @@ import noppes.npcs.quests.QuestKill; import noppes.npcs.quests.QuestLocation; import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.NpcAPI; -import noppes.npcs.scripted.handler.data.IQuest; -import noppes.npcs.scripted.handler.data.IQuestCategory; -import noppes.npcs.scripted.handler.data.IQuestInterface; -import noppes.npcs.scripted.handler.data.IQuestObjective; +import noppes.npcs.scripted.interfaces.handler.data.IQuest; +import noppes.npcs.scripted.interfaces.handler.data.IQuestCategory; +import noppes.npcs.scripted.interfaces.handler.data.IQuestInterface; +import noppes.npcs.scripted.interfaces.handler.data.IQuestObjective; import noppes.npcs.scripted.interfaces.IContainer; -import noppes.npcs.scripted.interfaces.IPlayer; +import noppes.npcs.scripted.interfaces.entity.IPlayer; public class Quest implements ICompatibilty, IQuest { public int version = VersionCompatibility.ModRev; diff --git a/src/main/java/noppes/npcs/controllers/QuestCategory.java b/src/main/java/noppes/npcs/controllers/QuestCategory.java index c4dac8490..10da9533b 100644 --- a/src/main/java/noppes/npcs/controllers/QuestCategory.java +++ b/src/main/java/noppes/npcs/controllers/QuestCategory.java @@ -6,8 +6,8 @@ import java.util.List; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import noppes.npcs.scripted.handler.data.IQuest; -import noppes.npcs.scripted.handler.data.IQuestCategory; +import noppes.npcs.scripted.interfaces.handler.data.IQuest; +import noppes.npcs.scripted.interfaces.handler.data.IQuestCategory; public class QuestCategory implements IQuestCategory { public HashMap quests; diff --git a/src/main/java/noppes/npcs/controllers/QuestController.java b/src/main/java/noppes/npcs/controllers/QuestController.java index 2e8c664d9..70a28819f 100644 --- a/src/main/java/noppes/npcs/controllers/QuestController.java +++ b/src/main/java/noppes/npcs/controllers/QuestController.java @@ -10,9 +10,9 @@ import net.minecraft.nbt.NBTTagList; import noppes.npcs.CustomNpcs; import noppes.npcs.LogWriter; import noppes.npcs.NoppesStringUtils; -import noppes.npcs.scripted.handler.IQuestHandler; -import noppes.npcs.scripted.handler.data.IQuest; -import noppes.npcs.scripted.handler.data.IQuestCategory; +import noppes.npcs.scripted.interfaces.handler.IQuestHandler; +import noppes.npcs.scripted.interfaces.handler.data.IQuest; +import noppes.npcs.scripted.interfaces.handler.data.IQuestCategory; import noppes.npcs.util.NBTJsonUtil; public class QuestController implements IQuestHandler { diff --git a/src/main/java/noppes/npcs/controllers/RecipeCarpentry.java b/src/main/java/noppes/npcs/controllers/RecipeCarpentry.java index 58089d2eb..44ae912bc 100644 --- a/src/main/java/noppes/npcs/controllers/RecipeCarpentry.java +++ b/src/main/java/noppes/npcs/controllers/RecipeCarpentry.java @@ -1,10 +1,7 @@ package noppes.npcs.controllers; import java.io.IOException; -import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; -import java.util.List; import net.minecraft.block.Block; import net.minecraft.inventory.InventoryCrafting; @@ -16,7 +13,7 @@ import net.minecraft.world.World; import noppes.npcs.NBTTags; import noppes.npcs.NoppesUtilPlayer; import noppes.npcs.NoppesUtilServer; -import noppes.npcs.scripted.handler.data.IRecipe; +import noppes.npcs.scripted.interfaces.handler.data.IRecipe; public class RecipeCarpentry extends ShapedRecipes implements IRecipe { public int id = -1; diff --git a/src/main/java/noppes/npcs/controllers/RecipeController.java b/src/main/java/noppes/npcs/controllers/RecipeController.java index a028f938f..b503490fd 100644 --- a/src/main/java/noppes/npcs/controllers/RecipeController.java +++ b/src/main/java/noppes/npcs/controllers/RecipeController.java @@ -13,8 +13,8 @@ import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.CustomNpcs; -import noppes.npcs.scripted.handler.IRecipeHandler; -import noppes.npcs.scripted.handler.data.IRecipe; +import noppes.npcs.scripted.interfaces.handler.IRecipeHandler; +import noppes.npcs.scripted.interfaces.handler.data.IRecipe; public class RecipeController implements IRecipeHandler { private static Collection prevRecipes; diff --git a/src/main/java/noppes/npcs/controllers/ServerCloneController.java b/src/main/java/noppes/npcs/controllers/ServerCloneController.java index 4dcb0ebcf..0462de388 100644 --- a/src/main/java/noppes/npcs/controllers/ServerCloneController.java +++ b/src/main/java/noppes/npcs/controllers/ServerCloneController.java @@ -2,11 +2,7 @@ package noppes.npcs.controllers; import java.io.File; import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -14,7 +10,6 @@ import java.util.Map; import net.minecraft.command.ICommandSender; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -22,13 +17,10 @@ import net.minecraft.util.ChatComponentText; import noppes.npcs.CustomNpcs; import noppes.npcs.LogWriter; import noppes.npcs.NoppesUtilServer; -import noppes.npcs.controllers.LinkedNpcController.LinkedData; import noppes.npcs.scripted.CustomNPCsException; -import noppes.npcs.scripted.NpcAPI; -import noppes.npcs.scripted.handler.ICloneHandler; -import noppes.npcs.scripted.interfaces.IEntity; +import noppes.npcs.scripted.interfaces.handler.ICloneHandler; +import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.IWorld; -import noppes.npcs.util.JsonException; import noppes.npcs.util.NBTJsonUtil; public class ServerCloneController implements ICloneHandler { diff --git a/src/main/java/noppes/npcs/controllers/data/NPCDataScript.java b/src/main/java/noppes/npcs/controllers/data/NPCDataScript.java index 44ea2681d..bf291a73a 100644 --- a/src/main/java/noppes/npcs/controllers/data/NPCDataScript.java +++ b/src/main/java/noppes/npcs/controllers/data/NPCDataScript.java @@ -11,8 +11,7 @@ import noppes.npcs.controllers.IScriptHandler; import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.controllers.ScriptController; import noppes.npcs.entity.EntityNPCInterface; -import noppes.npcs.scripted.NpcAPI; -import noppes.npcs.scripted.interfaces.ICustomNpc; +import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import javax.annotation.CheckForNull; import java.lang.reflect.Array; diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java b/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java index ab3e95477..60c916293 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java @@ -7,27 +7,22 @@ import java.lang.reflect.Array; import java.util.*; import java.util.Map.Entry; import com.google.common.base.Preconditions; -import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.BlockPos; import cpw.mods.fml.common.eventhandler.Event; -import net.minecraft.world.WorldServer; import noppes.npcs.CustomNpcs; import noppes.npcs.EventHooks; import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.NBTTags; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.constants.EnumScriptType; import noppes.npcs.controllers.IScriptHandler; import noppes.npcs.controllers.ScriptController; import noppes.npcs.scripted.entity.ScriptPlayer; -import noppes.npcs.scripted.event.PlayerEvent; -import noppes.npcs.scripted.interfaces.IPlayer; -import noppes.npcs.scripted.interfaces.IWorld; -import noppes.npcs.scripted.wrapper.WrapperNpcAPI; +import noppes.npcs.scripted.interfaces.entity.IPlayer; + import javax.annotation.CheckForNull; -import javax.script.ScriptEngine; + public class PlayerDataScript implements IScriptHandler { public List scripts = new ArrayList(); public String scriptLanguage = "ECMAScript"; diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 872cf6b74..b6481e015 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -61,7 +61,6 @@ import noppes.npcs.constants.EnumNavType; import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumPotionType; import noppes.npcs.constants.EnumRoleType; -import noppes.npcs.constants.EnumScriptType; import noppes.npcs.constants.EnumStandingType; import noppes.npcs.controllers.Dialog; import noppes.npcs.controllers.DialogOption; @@ -86,7 +85,7 @@ import noppes.npcs.scripted.event.ScriptEventAttack; import noppes.npcs.scripted.event.ScriptEventDamaged; import noppes.npcs.scripted.event.ScriptEventKilled; import noppes.npcs.scripted.event.ScriptEventTarget; -import noppes.npcs.scripted.interfaces.ICustomNpc; +import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import noppes.npcs.util.GameProfileAlt; import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; diff --git a/src/main/java/noppes/npcs/items/ItemScripted.java b/src/main/java/noppes/npcs/items/ItemScripted.java index 510c8fbbc..7438a5660 100644 --- a/src/main/java/noppes/npcs/items/ItemScripted.java +++ b/src/main/java/noppes/npcs/items/ItemScripted.java @@ -4,7 +4,6 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -22,8 +21,7 @@ import noppes.npcs.constants.EnumGuiType; import noppes.npcs.controllers.ScriptController; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.event.ItemEvent; -import noppes.npcs.scripted.interfaces.IItemStack; -import noppes.npcs.scripted.interfaces.IPlayer; +import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptCustomItem; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/noppes/npcs/quests/QuestDialog.java b/src/main/java/noppes/npcs/quests/QuestDialog.java index 0ce52a2f8..aee27eabe 100644 --- a/src/main/java/noppes/npcs/quests/QuestDialog.java +++ b/src/main/java/noppes/npcs/quests/QuestDialog.java @@ -14,8 +14,8 @@ import noppes.npcs.controllers.DialogController; import noppes.npcs.controllers.PlayerData; import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.scripted.CustomNPCsException; -import noppes.npcs.scripted.handler.data.IQuestDialog; -import noppes.npcs.scripted.handler.data.IQuestObjective; +import noppes.npcs.scripted.interfaces.handler.data.IQuestDialog; +import noppes.npcs.scripted.interfaces.handler.data.IQuestObjective; public class QuestDialog extends QuestInterface implements IQuestDialog { diff --git a/src/main/java/noppes/npcs/quests/QuestInterface.java b/src/main/java/noppes/npcs/quests/QuestInterface.java index 3f7ceb87e..b385471fc 100644 --- a/src/main/java/noppes/npcs/quests/QuestInterface.java +++ b/src/main/java/noppes/npcs/quests/QuestInterface.java @@ -5,8 +5,8 @@ import java.util.Vector; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.controllers.PlayerData; -import noppes.npcs.scripted.handler.data.IQuestInterface; -import noppes.npcs.scripted.handler.data.IQuestObjective; +import noppes.npcs.scripted.interfaces.handler.data.IQuestInterface; +import noppes.npcs.scripted.interfaces.handler.data.IQuestObjective; public abstract class QuestInterface implements IQuestInterface { public int questId; diff --git a/src/main/java/noppes/npcs/quests/QuestItem.java b/src/main/java/noppes/npcs/quests/QuestItem.java index a8817b28d..dc6be0aa6 100644 --- a/src/main/java/noppes/npcs/quests/QuestItem.java +++ b/src/main/java/noppes/npcs/quests/QuestItem.java @@ -10,8 +10,8 @@ import noppes.npcs.NoppesUtilServer; import noppes.npcs.NpcMiscInventory; import noppes.npcs.controllers.PlayerData; import noppes.npcs.scripted.CustomNPCsException; -import noppes.npcs.scripted.handler.data.IQuestItem; -import noppes.npcs.scripted.handler.data.IQuestObjective; +import noppes.npcs.scripted.interfaces.handler.data.IQuestItem; +import noppes.npcs.scripted.interfaces.handler.data.IQuestObjective; import noppes.npcs.util.ValueUtil; public class QuestItem extends QuestInterface implements IQuestItem { diff --git a/src/main/java/noppes/npcs/quests/QuestKill.java b/src/main/java/noppes/npcs/quests/QuestKill.java index b5f6b84a3..08be78a53 100644 --- a/src/main/java/noppes/npcs/quests/QuestKill.java +++ b/src/main/java/noppes/npcs/quests/QuestKill.java @@ -2,9 +2,6 @@ package noppes.npcs.quests; import java.util.*; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.NBTTags; @@ -14,8 +11,8 @@ import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.PlayerQuestData; import noppes.npcs.controllers.QuestData; import noppes.npcs.scripted.CustomNPCsException; -import noppes.npcs.scripted.handler.data.IQuestKill; -import noppes.npcs.scripted.handler.data.IQuestObjective; +import noppes.npcs.scripted.interfaces.handler.data.IQuestKill; +import noppes.npcs.scripted.interfaces.handler.data.IQuestObjective; public class QuestKill extends QuestInterface implements IQuestKill { public HashMap targets = new HashMap(); diff --git a/src/main/java/noppes/npcs/quests/QuestLocation.java b/src/main/java/noppes/npcs/quests/QuestLocation.java index 15c04fdc5..5b9f7d84c 100644 --- a/src/main/java/noppes/npcs/quests/QuestLocation.java +++ b/src/main/java/noppes/npcs/quests/QuestLocation.java @@ -13,8 +13,8 @@ import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.PlayerQuestData; import noppes.npcs.controllers.QuestData; import noppes.npcs.scripted.CustomNPCsException; -import noppes.npcs.scripted.handler.data.IQuestLocation; -import noppes.npcs.scripted.handler.data.IQuestObjective; +import noppes.npcs.scripted.interfaces.handler.data.IQuestLocation; +import noppes.npcs.scripted.interfaces.handler.data.IQuestObjective; public class QuestLocation extends QuestInterface implements IQuestLocation { public String location = ""; diff --git a/src/main/java/noppes/npcs/scripted/NpcAPI.java b/src/main/java/noppes/npcs/scripted/NpcAPI.java index db93c27f7..0280d43b2 100644 --- a/src/main/java/noppes/npcs/scripted/NpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/NpcAPI.java @@ -20,7 +20,9 @@ import net.minecraft.world.World; import net.minecraft.world.WorldServer; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.interfaces.*; -import noppes.npcs.scripted.item.ScriptItemStack; +import noppes.npcs.scripted.interfaces.entity.ICustomNpc; +import noppes.npcs.scripted.interfaces.entity.IEntity; +import noppes.npcs.scripted.interfaces.item.IItemStack; public abstract class NpcAPI { private static NpcAPI instance = null; diff --git a/src/main/java/noppes/npcs/scripted/ScriptContainer.java b/src/main/java/noppes/npcs/scripted/ScriptContainer.java index d0197fcd2..a607d1431 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptContainer.java +++ b/src/main/java/noppes/npcs/scripted/ScriptContainer.java @@ -14,7 +14,7 @@ import noppes.npcs.NoppesUtilPlayer; import noppes.npcs.containers.ContainerCustomGui; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.interfaces.IContainer; -import noppes.npcs.scripted.interfaces.IItemStack; +import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptItemStack; public class ScriptContainer implements IContainer { diff --git a/src/main/java/noppes/npcs/scripted/ScriptParticle.java b/src/main/java/noppes/npcs/scripted/ScriptParticle.java index 9fc33a4dd..04ba712ce 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptParticle.java +++ b/src/main/java/noppes/npcs/scripted/ScriptParticle.java @@ -2,11 +2,12 @@ package noppes.npcs.scripted; import noppes.npcs.NoppesUtilServer; import noppes.npcs.scripted.entity.ScriptEntity; +import noppes.npcs.scripted.interfaces.IParticle; /** * Created by luisc on 9/8/2021. */ -public class ScriptParticle { +public class ScriptParticle implements IParticle { private String directory; private int HEXColor = 0xFFFFFF; @@ -139,42 +140,14 @@ public class ScriptParticle { return directory; } + @Deprecated public void setHEXColor(int HEXColor) { this.HEXColor = HEXColor; } + @Deprecated public int getHEXColor() { return HEXColor; } - public void setHEXColor(int HEXColor, int HEXColor2, float HEXColorRate, int HEXColorStart) { - this.HEXColor = HEXColor; - this.HEXColor2 = HEXColor2; - this.HEXColorRate = HEXColorRate; - this.HEXColorStart = HEXColorStart; - } - public int getHEXColor1() { - return HEXColor; - } - public int getHEXColor2() { - return HEXColor2; - } - public float getHEXColorRate() { - return HEXColorRate; - } - public int getHEXColorStart() { - return HEXColorStart; - } - public void setHEXColor1(int HEXColor) { - this.HEXColor = HEXColor; - } - public void setHEXColor2(int HEXColor2) { - this.HEXColor2 = HEXColor2; - } - public void setHEXColorRate(float HEXColorRate) { - this.HEXColorRate = HEXColorRate; - } - public void setHEXColorStart(int HEXColorStart) { - this.HEXColorStart = HEXColorStart; - } public int getAmount() { return amount; @@ -207,6 +180,19 @@ public class ScriptParticle { return gravity; } + public int getHEXColor1() { + return HEXColor; + } + public int getHEXColor2() { + return HEXColor2; + } + public float getHEXColorRate() { + return HEXColorRate; + } + public int getHEXColorStart() { + return HEXColorStart; + } + public float getAlpha1() { return alpha1; } @@ -294,23 +280,23 @@ public class ScriptParticle { this.gravity = gravity; } - public void setScale(float scale1, float scale2, float scaleRate, int scaleRateStart){ - this.scale1 = scale1; - this.scale2 = scale2; - this.scaleRate = scaleRate; - this.scaleRateStart = scaleRateStart; + public void setHEXColor(int HEXColor, int HEXColor2, float HEXColorRate, int HEXColorStart) { + this.HEXColor = HEXColor; + this.HEXColor2 = HEXColor2; + this.HEXColorRate = HEXColorRate; + this.HEXColorStart = HEXColorStart; } - public void setScale1(float scale1) { - this.scale1 = scale1; + public void setHEXColor1(int HEXColor) { + this.HEXColor = HEXColor; } - public void setScale2(float scale2) { - this.scale2 = scale2; + public void setHEXColor2(int HEXColor2) { + this.HEXColor2 = HEXColor2; } - public void setScaleRate(float scaleRate) { - this.scaleRate = scaleRate; + public void setHEXColorRate(float HEXColorRate) { + this.HEXColorRate = HEXColorRate; } - public void setScaleRateStart(int scaleRateStart) { - this.scaleRateStart = scaleRateStart; + public void setHEXColorStart(int HEXColorStart) { + this.HEXColorStart = HEXColorStart; } public void setAlpha(float alpha1, float alpha2, float alphaRate, int alphaRateStart){ @@ -332,6 +318,25 @@ public class ScriptParticle { this.alphaRateStart = alphaRateStart; } + public void setScale(float scale1, float scale2, float scaleRate, int scaleRateStart){ + this.scale1 = scale1; + this.scale2 = scale2; + this.scaleRate = scaleRate; + this.scaleRateStart = scaleRateStart; + } + public void setScale1(float scale1) { + this.scale1 = scale1; + } + public void setScale2(float scale2) { + this.scale2 = scale2; + } + public void setScaleRate(float scaleRate) { + this.scaleRate = scaleRate; + } + public void setScaleRateStart(int scaleRateStart) { + this.scaleRateStart = scaleRateStart; + } + public void setRotationX(float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart){ this.rotationX1 = rotationX1; this.rotationX2 = rotationX2; diff --git a/src/main/java/noppes/npcs/scripted/ScriptWorld.java b/src/main/java/noppes/npcs/scripted/ScriptWorld.java index a25c9ad21..61af7f4d7 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptWorld.java +++ b/src/main/java/noppes/npcs/scripted/ScriptWorld.java @@ -11,8 +11,6 @@ import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTBase.NBTPrimitive; import net.minecraft.nbt.NBTTagCompound; @@ -26,14 +24,12 @@ import noppes.npcs.NoppesUtilServer; import noppes.npcs.blocks.tiles.TileBigSign; import noppes.npcs.controllers.ScriptController; import noppes.npcs.controllers.ServerCloneController; -import noppes.npcs.items.ItemScripted; import noppes.npcs.scripted.entity.ScriptEntity; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.interfaces.IBlock; -import noppes.npcs.scripted.interfaces.IEntity; -import noppes.npcs.scripted.interfaces.IItemStack; +import noppes.npcs.scripted.interfaces.entity.IEntity; +import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.IWorld; -import noppes.npcs.scripted.item.ScriptCustomItem; import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.wrapper.WrapperNpcAPI; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptAnimal.java b/src/main/java/noppes/npcs/scripted/entity/ScriptAnimal.java index e1217aedb..33f0b28d5 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptAnimal.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptAnimal.java @@ -2,7 +2,7 @@ package noppes.npcs.scripted.entity; import net.minecraft.entity.passive.EntityAnimal; import noppes.npcs.scripted.constants.EntityType; -import noppes.npcs.scripted.interfaces.IAnimal; +import noppes.npcs.scripted.interfaces.entity.IAnimal; public class ScriptAnimal extends ScriptLiving implements IAnimal { diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java index 0a61009c2..5752053c6 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java @@ -5,7 +5,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.scripted.CustomNPCsException; -import noppes.npcs.scripted.interfaces.IItemStack; +import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptItemStack; public class ScriptDBCPlayer extends ScriptPlayer{ diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index 8b6cf2339..461825c64 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -25,7 +25,7 @@ import noppes.npcs.controllers.ServerCloneController; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.*; import noppes.npcs.scripted.constants.EntityType; -import noppes.npcs.scripted.interfaces.IEntity; +import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.INbt; import noppes.npcs.scripted.interfaces.IPos; import noppes.npcs.scripted.item.ScriptItemStack; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptLiving.java b/src/main/java/noppes/npcs/scripted/entity/ScriptLiving.java index 9b06e5625..d175e78fd 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptLiving.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptLiving.java @@ -2,7 +2,7 @@ package noppes.npcs.scripted.entity; import net.minecraft.entity.EntityLiving; import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.interfaces.IEntityLiving; +import noppes.npcs.scripted.interfaces.entity.IEntityLiving; public class ScriptLiving extends ScriptLivingBase implements IEntityLiving { diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java index eef846d2b..8f41c8971 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java @@ -2,16 +2,15 @@ package noppes.npcs.scripted.entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; import net.minecraft.util.EntityDamageSource; import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.interfaces.IItemStack; +import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.constants.EntityType; -import noppes.npcs.scripted.interfaces.IEntityLivingBase; +import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; import noppes.npcs.scripted.wrapper.ScriptDamageSource; import noppes.npcs.scripted.wrapper.WrapperNpcAPI; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptMonster.java b/src/main/java/noppes/npcs/scripted/entity/ScriptMonster.java index 8e7afdd8e..16dcc71c6 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptMonster.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptMonster.java @@ -2,7 +2,7 @@ package noppes.npcs.scripted.entity; import net.minecraft.entity.monster.EntityMob; import noppes.npcs.scripted.constants.EntityType; -import noppes.npcs.scripted.interfaces.IMonster; +import noppes.npcs.scripted.interfaces.entity.IMonster; public class ScriptMonster extends ScriptLiving implements IMonster { diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index cbfccf986..631cbaf3b 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -1,6 +1,5 @@ package noppes.npcs.scripted.entity; -import net.minecraft.item.ItemStack; import noppes.npcs.CustomNpcs; import noppes.npcs.NoppesUtilServer; import noppes.npcs.constants.*; @@ -8,11 +7,11 @@ import noppes.npcs.controllers.Line; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.ScriptFaction; -import noppes.npcs.scripted.interfaces.IItemStack; +import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.constants.AnimationType; import noppes.npcs.scripted.constants.EntityType; -import noppes.npcs.scripted.interfaces.ICustomNpc; +import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import noppes.npcs.scripted.interfaces.ITimers; import noppes.npcs.scripted.roles.ScriptJobBard; import noppes.npcs.scripted.roles.ScriptJobConversation; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPixelmon.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPixelmon.java index 727ca20e8..ab845e2a0 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPixelmon.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPixelmon.java @@ -3,7 +3,7 @@ package noppes.npcs.scripted.entity; import net.minecraft.entity.passive.EntityTameable; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.controllers.PixelmonHelper; -import noppes.npcs.scripted.interfaces.IPixelmon; +import noppes.npcs.scripted.interfaces.entity.IPixelmon; import noppes.npcs.util.ValueUtil; public class ScriptPixelmon extends ScriptAnimal implements IPixelmon { diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index 1aa268b86..9ceb1083b 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -20,8 +20,12 @@ import noppes.npcs.entity.EntityDialogNpc; import noppes.npcs.scripted.*; import noppes.npcs.scripted.constants.EntityType; import noppes.npcs.scripted.gui.ScriptGui; -import noppes.npcs.scripted.handler.data.IQuest; +import noppes.npcs.scripted.interfaces.handler.data.IQuest; import noppes.npcs.scripted.interfaces.*; +import noppes.npcs.scripted.interfaces.entity.IPlayer; +import noppes.npcs.scripted.interfaces.gui.ICustomGui; +import noppes.npcs.scripted.interfaces.item.IItemStack; +import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay; import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.overlay.ScriptOverlay; import noppes.npcs.scripted.wrapper.WrapperNpcAPI; diff --git a/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java b/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java index 6c20658d0..2fa0b09eb 100644 --- a/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/CustomGuiEvent.java @@ -1,9 +1,9 @@ package noppes.npcs.scripted.event; import cpw.mods.fml.common.eventhandler.Event; -import noppes.npcs.scripted.interfaces.ICustomGui; -import noppes.npcs.scripted.interfaces.IItemStack; -import noppes.npcs.scripted.interfaces.IPlayer; +import noppes.npcs.scripted.interfaces.gui.ICustomGui; +import noppes.npcs.scripted.interfaces.item.IItemStack; +import noppes.npcs.scripted.interfaces.entity.IPlayer; public class CustomGuiEvent extends Event { public final IPlayer player; diff --git a/src/main/java/noppes/npcs/scripted/event/DialogEvent.java b/src/main/java/noppes/npcs/scripted/event/DialogEvent.java index 8e9f9b34f..00a8913e9 100644 --- a/src/main/java/noppes/npcs/scripted/event/DialogEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/DialogEvent.java @@ -1,7 +1,7 @@ package noppes.npcs.scripted.event; -import noppes.npcs.scripted.handler.data.IDialog; -import noppes.npcs.scripted.interfaces.IPlayer; +import noppes.npcs.scripted.interfaces.handler.data.IDialog; +import noppes.npcs.scripted.interfaces.entity.IPlayer; public class DialogEvent extends CustomNPCsEvent { public final IDialog dialog; diff --git a/src/main/java/noppes/npcs/scripted/event/FactionEvent.java b/src/main/java/noppes/npcs/scripted/event/FactionEvent.java index 34e56d692..4f9d59217 100644 --- a/src/main/java/noppes/npcs/scripted/event/FactionEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/FactionEvent.java @@ -1,7 +1,7 @@ package noppes.npcs.scripted.event; -import noppes.npcs.scripted.handler.data.IFaction; -import noppes.npcs.scripted.interfaces.IPlayer; +import noppes.npcs.scripted.interfaces.handler.data.IFaction; +import noppes.npcs.scripted.interfaces.entity.IPlayer; public class FactionEvent extends CustomNPCsEvent { public final IFaction faction; diff --git a/src/main/java/noppes/npcs/scripted/event/ForgeEvent.java b/src/main/java/noppes/npcs/scripted/event/ForgeEvent.java index 29c03b5a8..20eece91b 100644 --- a/src/main/java/noppes/npcs/scripted/event/ForgeEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/ForgeEvent.java @@ -8,7 +8,7 @@ package noppes.npcs.scripted.event; import cpw.mods.fml.common.eventhandler.Cancelable; import cpw.mods.fml.common.eventhandler.Event; import noppes.npcs.scripted.interfaces.IWorld; -import noppes.npcs.scripted.interfaces.IEntity; +import noppes.npcs.scripted.interfaces.entity.IEntity; @Cancelable public class ForgeEvent extends CustomNPCsEvent { diff --git a/src/main/java/noppes/npcs/scripted/event/ItemEvent.java b/src/main/java/noppes/npcs/scripted/event/ItemEvent.java index 87663eada..679db5203 100644 --- a/src/main/java/noppes/npcs/scripted/event/ItemEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/ItemEvent.java @@ -1,13 +1,9 @@ package noppes.npcs.scripted.event; import cpw.mods.fml.common.eventhandler.Cancelable; -import net.minecraft.item.ItemStack; -import noppes.npcs.scripted.NpcAPI; -import noppes.npcs.scripted.interfaces.ICustomItem; -import noppes.npcs.scripted.interfaces.IEntity; -import noppes.npcs.scripted.interfaces.IItemStack; -import noppes.npcs.scripted.interfaces.IPlayer; -import noppes.npcs.scripted.item.ScriptCustomItem; +import noppes.npcs.scripted.interfaces.item.ICustomItem; +import noppes.npcs.scripted.interfaces.entity.IEntity; +import noppes.npcs.scripted.interfaces.entity.IPlayer; public class ItemEvent extends CustomNPCsEvent { public ICustomItem item; diff --git a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java index 2407cd8c7..e0ffe6a8c 100644 --- a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java @@ -14,6 +14,11 @@ import noppes.npcs.controllers.Dialog; import noppes.npcs.controllers.ScriptController; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.*; +import noppes.npcs.scripted.interfaces.entity.ICustomNpc; +import noppes.npcs.scripted.interfaces.entity.IEntity; +import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; +import noppes.npcs.scripted.interfaces.entity.IPlayer; +import noppes.npcs.scripted.interfaces.item.IItemStack; public class NpcEvent extends CustomNPCsEvent { public final ICustomNpc npc; diff --git a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java index 0f1dbfb3c..f702353a2 100644 --- a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java @@ -16,6 +16,10 @@ import noppes.npcs.controllers.ScriptController; import noppes.npcs.scripted.*; import noppes.npcs.scripted.entity.ScriptLivingBase; import noppes.npcs.scripted.interfaces.*; +import noppes.npcs.scripted.interfaces.entity.IEntity; +import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; +import noppes.npcs.scripted.interfaces.entity.IPlayer; +import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptItemStack; public class PlayerEvent extends CustomNPCsEvent { diff --git a/src/main/java/noppes/npcs/scripted/event/QuestEvent.java b/src/main/java/noppes/npcs/scripted/event/QuestEvent.java index 24ae2eaaf..717842057 100644 --- a/src/main/java/noppes/npcs/scripted/event/QuestEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/QuestEvent.java @@ -1,9 +1,9 @@ package noppes.npcs.scripted.event; import cpw.mods.fml.common.eventhandler.Cancelable; -import noppes.npcs.scripted.handler.data.IQuest; -import noppes.npcs.scripted.interfaces.IItemStack; -import noppes.npcs.scripted.interfaces.IPlayer; +import noppes.npcs.scripted.interfaces.handler.data.IQuest; +import noppes.npcs.scripted.interfaces.item.IItemStack; +import noppes.npcs.scripted.interfaces.entity.IPlayer; public class QuestEvent extends CustomNPCsEvent { public final IQuest quest; diff --git a/src/main/java/noppes/npcs/scripted/event/ScriptEventDialog.java b/src/main/java/noppes/npcs/scripted/event/ScriptEventDialog.java index fd73d1fcc..06189f348 100644 --- a/src/main/java/noppes/npcs/scripted/event/ScriptEventDialog.java +++ b/src/main/java/noppes/npcs/scripted/event/ScriptEventDialog.java @@ -3,8 +3,7 @@ package noppes.npcs.scripted.event; import net.minecraft.entity.player.EntityPlayer; import noppes.npcs.controllers.Dialog; import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.NpcAPI; -import noppes.npcs.scripted.interfaces.IPlayer; +import noppes.npcs.scripted.interfaces.entity.IPlayer; public class ScriptEventDialog extends ScriptEvent{ public IPlayer player; diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGui.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGui.java index c840cff66..893ef2dc6 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGui.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGui.java @@ -13,12 +13,11 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.controllers.ScriptController; import noppes.npcs.controllers.data.PlayerDataScript; -import noppes.npcs.scripted.interfaces.*; -import noppes.npcs.scripted.interfaces.ICustomGuiComponent; +import noppes.npcs.scripted.interfaces.gui.*; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.controllers.CustomGuiController; -import noppes.npcs.controllers.ScriptContainer; -import noppes.npcs.scripted.interfaces.ICustomGui; +import noppes.npcs.scripted.interfaces.entity.IPlayer; +import noppes.npcs.scripted.interfaces.item.IItemStack; public class ScriptGui implements ICustomGui { int id; diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiButton.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiButton.java index 1ac8418ab..d6f1e16cb 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiButton.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiButton.java @@ -1,8 +1,8 @@ package noppes.npcs.scripted.gui; import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.scripted.interfaces.IButton; -import noppes.npcs.scripted.interfaces.ICustomGuiComponent; +import noppes.npcs.scripted.interfaces.gui.IButton; +import noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent; public class ScriptGuiButton extends ScriptGuiComponent implements IButton { int width; diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiComponent.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiComponent.java index 7d7f8d405..9b26a30c5 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiComponent.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiComponent.java @@ -3,8 +3,7 @@ package noppes.npcs.scripted.gui; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; -import noppes.npcs.scripted.interfaces.ICustomGuiComponent; -import noppes.npcs.scripted.interfaces.ICustomOverlayComponent; +import noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent; public abstract class ScriptGuiComponent implements ICustomGuiComponent { int id; diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiItemSlot.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiItemSlot.java index 68c81abdf..9bd829d73 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiItemSlot.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiItemSlot.java @@ -4,8 +4,8 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.scripted.NpcAPI; -import noppes.npcs.scripted.interfaces.IItemSlot; -import noppes.npcs.scripted.interfaces.IItemStack; +import noppes.npcs.scripted.interfaces.gui.IItemSlot; +import noppes.npcs.scripted.interfaces.item.IItemStack; public class ScriptGuiItemSlot extends ScriptGuiComponent implements IItemSlot { IItemStack stack; diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLabel.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLabel.java index 53ade2d95..5e6abcab7 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLabel.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLabel.java @@ -1,7 +1,7 @@ package noppes.npcs.scripted.gui; import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.scripted.interfaces.ILabel; +import noppes.npcs.scripted.interfaces.gui.ILabel; public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel { String label; diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLine.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLine.java index c59a425c0..3ba59b0c9 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLine.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiLine.java @@ -1,7 +1,7 @@ package noppes.npcs.scripted.gui; import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.scripted.interfaces.ILine; +import noppes.npcs.scripted.interfaces.gui.ILine; public class ScriptGuiLine extends ScriptGuiComponent implements ILine { int x1; diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiScroll.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiScroll.java index d06b0bcae..58604653e 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiScroll.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiScroll.java @@ -3,7 +3,7 @@ package noppes.npcs.scripted.gui; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; -import noppes.npcs.scripted.interfaces.IScroll; +import noppes.npcs.scripted.interfaces.gui.IScroll; public class ScriptGuiScroll extends ScriptGuiComponent implements IScroll { int width; diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiTextField.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiTextField.java index a492047cc..aea2a50ee 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiTextField.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiTextField.java @@ -1,7 +1,7 @@ package noppes.npcs.scripted.gui; import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.scripted.interfaces.ITextField; +import noppes.npcs.scripted.interfaces.gui.ITextField; public class ScriptGuiTextField extends ScriptGuiComponent implements ITextField { int width; diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiTexturedRect.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiTexturedRect.java index 051ef6592..3fc98a3c2 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiTexturedRect.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiTexturedRect.java @@ -1,7 +1,7 @@ package noppes.npcs.scripted.gui; import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.scripted.interfaces.ITexturedRect; +import noppes.npcs.scripted.interfaces.gui.ITexturedRect; public class ScriptGuiTexturedRect extends ScriptGuiComponent implements ITexturedRect { int width; diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IQuestInterface.java b/src/main/java/noppes/npcs/scripted/handler/data/IQuestInterface.java deleted file mode 100644 index 5edc4f1e0..000000000 --- a/src/main/java/noppes/npcs/scripted/handler/data/IQuestInterface.java +++ /dev/null @@ -1,4 +0,0 @@ -package noppes.npcs.scripted.handler.data; - -public interface IQuestInterface { -} diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java b/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java index e874fe901..15a474c8d 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java @@ -7,6 +7,7 @@ package noppes.npcs.scripted.interfaces; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; +import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.entity.ScriptPlayer; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java b/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java index 8008559d4..529db409c 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java @@ -6,6 +6,7 @@ package noppes.npcs.scripted.interfaces; import net.minecraft.util.DamageSource; +import noppes.npcs.scripted.interfaces.entity.IEntity; public interface IDamageSource { String getType(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java b/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java new file mode 100644 index 000000000..e3b3c4cd2 --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java @@ -0,0 +1,134 @@ +package noppes.npcs.scripted.interfaces; + +import noppes.npcs.NoppesUtilServer; +import noppes.npcs.scripted.ScriptWorld; +import noppes.npcs.scripted.entity.ScriptEntity; + +public interface IParticle { + + void spawnOnEntity(ScriptEntity entity); + + void spawnInWorld(ScriptWorld world); + + void spawnInWorld(ScriptWorld world, double x, double y, double z); + + void setSize(int width, int height); + int getWidth(); + int getHeight(); + + void setOffset(int offsetX, int offsetY); + int getOffsetX(); + int getOffsetY(); + + void setAnim(int animRate, boolean animLoop, int animStart, int animEnd); + void setAnimRate(int animRate); + int getAnimRate(); + void setAnimLoop(boolean animLoop); + boolean getAnimLoop(); + void setAnimStart(int animStart); + int getAnimStart(); + void setAnimEnd(int animEnd); + int getAnimEnd(); + + boolean getFacePlayer(); + void setFacePlayer(boolean facePlayer); + + String getDirectory(); + + int getAmount(); + + int getMaxAge(); + + double getX(); + double getY(); + double getZ(); + + double getMotionX(); + double getMotionY(); + double getMotionZ(); + float getGravity(); + + int getHEXColor1(); + int getHEXColor2(); + float getHEXColorRate(); + int getHEXColorStart(); + + float getAlpha1(); + float getAlpha2(); + float getAlphaRate(); + int getAlphaRateStart(); + + float getScale1(); + float getScale2(); + float getScaleRate(); + int getScaleRateStart(); + + float getRotationX1(); + float getRotationX2(); + float getRotationXRate(); + int getRotationXRateStart(); + + float getRotationY1(); + float getRotationY2(); + float getRotationYRate(); + int getRotationYRateStart(); + + float getRotationZ1(); + float getRotationZ2(); + float getRotationZRate(); + int getRotationZRateStart(); + + void setDirectory(String directory); + + void setAmount(int amount); + + void setMaxAge(int maxAge); + + void setPosition(double x, double y, double z); + void setX(double x); + void setY(double y); + void setZ(double z); + + void setMotion(double motionX, double motionY, double motionZ, float gravity); + void setMotionX(double motionX); + void setMotionY(double motionY); + void setMotionZ(double motionZ); + void setGravity(float gravity); + + void setHEXColor(int HEXColor, int HEXColor2, float HEXColorRate, int HEXColorStart); + void setHEXColor1(int HEXColor); + void setHEXColor2(int HEXColor2); + void setHEXColorRate(float HEXColorRate); + void setHEXColorStart(int HEXColorStart); + + void setAlpha(float alpha1, float alpha2, float alphaRate, int alphaRateStart); + void setAlpha1(float alpha1); + void setAlpha2(float alpha2); + void setAlphaRate(float alphaRate); + void setAlphaRateStart(int alphaRateStart); + + void setScale(float scale1, float scale2, float scaleRate, int scaleRateStart); + void setScale1(float scale1); + void setScale2(float scale2); + void setScaleRate(float scaleRate); + void setScaleRateStart(int scaleRateStart); + + void setRotationX(float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart); + void setRotationX1(float rotationX1); + void setRotationX2(float rotationX2); + void setRotationXRate(float rotationXRate); + void setRotationXRateStart(int rotationXRateStart); + + void setRotationY(float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart); + void setRotationY1(float rotationY1); + void setRotationY2(float rotationY2); + void setRotationYRate(float rotationYRate); + void setRotationYRateStart(int rotationYRateStart); + + void setRotationZ(float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart); + void setRotationZ1(float rotationZ1); + void setRotationZ2(float rotationZ2); + void setRotationZRate(float rotationZRate); + void setRotationZRateStart(int rotationZRateStart); + +} diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java index 2366be675..cf18f8088 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java @@ -5,6 +5,8 @@ import net.minecraft.world.WorldServer; import noppes.npcs.scripted.*; import noppes.npcs.scripted.entity.ScriptEntity; import noppes.npcs.scripted.entity.ScriptPlayer; +import noppes.npcs.scripted.interfaces.entity.IEntity; +import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptItemStack; public interface IWorld { diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IAnimal.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IAnimal.java similarity index 83% rename from src/main/java/noppes/npcs/scripted/interfaces/IAnimal.java rename to src/main/java/noppes/npcs/scripted/interfaces/entity/IAnimal.java index 4bf435547..28a74b2ae 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IAnimal.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IAnimal.java @@ -3,7 +3,7 @@ // (powered by Fernflower decompiler) // -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.entity; import net.minecraft.entity.passive.EntityAnimal; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java similarity index 99% rename from src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java rename to src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java index 1e2b0596e..e46ccd53f 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java @@ -3,10 +3,12 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.entity; import net.minecraft.entity.EntityCreature; import noppes.npcs.scripted.ScriptFaction; +import noppes.npcs.scripted.interfaces.item.IItemStack; +import noppes.npcs.scripted.interfaces.ITimers; import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.entity.ScriptLivingBase; import noppes.npcs.scripted.entity.ScriptPlayer; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java similarity index 98% rename from src/main/java/noppes/npcs/scripted/interfaces/IEntity.java rename to src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java index 8e9708095..69f2bbbe3 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IEntity.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java @@ -3,7 +3,7 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.entity; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; @@ -13,6 +13,8 @@ import noppes.npcs.scripted.ScriptBlockPos; import noppes.npcs.scripted.ScriptParticle; import noppes.npcs.scripted.ScriptWorld; import noppes.npcs.scripted.entity.ScriptEntity; +import noppes.npcs.scripted.interfaces.INbt; +import noppes.npcs.scripted.interfaces.IPos; import noppes.npcs.scripted.item.ScriptItemStack; public interface IEntity { diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IEntityLiving.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntityLiving.java similarity index 89% rename from src/main/java/noppes/npcs/scripted/interfaces/IEntityLiving.java rename to src/main/java/noppes/npcs/scripted/interfaces/entity/IEntityLiving.java index 4fda07e84..6adef4fe3 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IEntityLiving.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntityLiving.java @@ -3,7 +3,7 @@ // (powered by Fernflower decompiler) // -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.entity; import net.minecraft.entity.EntityLiving; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IEntityLivingBase.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntityLivingBase.java similarity index 95% rename from src/main/java/noppes/npcs/scripted/interfaces/IEntityLivingBase.java rename to src/main/java/noppes/npcs/scripted/interfaces/entity/IEntityLivingBase.java index e9eba3c39..f4c000eb1 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IEntityLivingBase.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntityLivingBase.java @@ -1,9 +1,8 @@ -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.DamageSource; -import net.minecraft.util.EntityDamageSource; import noppes.npcs.scripted.entity.ScriptEntity; +import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.entity.ScriptLivingBase; import noppes.npcs.scripted.wrapper.ScriptDamageSource; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IMonster.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IMonster.java similarity index 82% rename from src/main/java/noppes/npcs/scripted/interfaces/IMonster.java rename to src/main/java/noppes/npcs/scripted/interfaces/entity/IMonster.java index 99baf9350..0ab8598f0 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IMonster.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IMonster.java @@ -3,7 +3,7 @@ // (powered by Fernflower decompiler) // -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.entity; import net.minecraft.entity.monster.EntityMob; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IPixelmon.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IPixelmon.java similarity index 96% rename from src/main/java/noppes/npcs/scripted/interfaces/IPixelmon.java rename to src/main/java/noppes/npcs/scripted/interfaces/entity/IPixelmon.java index fb521efc4..7390887c1 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IPixelmon.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IPixelmon.java @@ -3,11 +3,9 @@ // (powered by Fernflower decompiler) // -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.entity; import net.minecraft.entity.passive.EntityTameable; -import noppes.npcs.controllers.PixelmonHelper; -import noppes.npcs.util.ValueUtil; public interface IPixelmon extends IAnimal { boolean getIsShiny(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IPlayer.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java similarity index 91% rename from src/main/java/noppes/npcs/scripted/interfaces/IPlayer.java rename to src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java index 18d6cf552..9539c928b 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IPlayer.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java @@ -1,26 +1,17 @@ -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.entity; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.Server; -import noppes.npcs.constants.EnumPacketClient; -import noppes.npcs.containers.ContainerCustomGui; -import noppes.npcs.controllers.*; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.ScriptBlock; import noppes.npcs.scripted.entity.ScriptDBCPlayer; import noppes.npcs.scripted.entity.ScriptEntity; -import noppes.npcs.scripted.gui.ScriptGui; -import noppes.npcs.scripted.handler.data.IQuest; +import noppes.npcs.scripted.interfaces.handler.data.IQuest; +import noppes.npcs.scripted.interfaces.*; +import noppes.npcs.scripted.interfaces.gui.ICustomGui; +import noppes.npcs.scripted.interfaces.item.IItemStack; +import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay; import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.ScriptPixelmonPlayerData; -import noppes.npcs.scripted.overlay.ScriptOverlay; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Set; public interface IPlayer extends IEntityLivingBase { /** diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IButton.java b/src/main/java/noppes/npcs/scripted/interfaces/gui/IButton.java similarity index 91% rename from src/main/java/noppes/npcs/scripted/interfaces/IButton.java rename to src/main/java/noppes/npcs/scripted/interfaces/gui/IButton.java index 06252a0a8..d7d420fc4 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IButton.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/gui/IButton.java @@ -3,7 +3,7 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.gui; public interface IButton extends ICustomGuiComponent { int getWidth(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ICustomGui.java b/src/main/java/noppes/npcs/scripted/interfaces/gui/ICustomGui.java similarity index 92% rename from src/main/java/noppes/npcs/scripted/interfaces/ICustomGui.java rename to src/main/java/noppes/npcs/scripted/interfaces/gui/ICustomGui.java index bb927e68d..3622f16ce 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ICustomGui.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/gui/ICustomGui.java @@ -3,9 +3,11 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.gui; import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.scripted.interfaces.item.IItemStack; +import noppes.npcs.scripted.interfaces.entity.IPlayer; import java.util.List; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ICustomGuiComponent.java b/src/main/java/noppes/npcs/scripted/interfaces/gui/ICustomGuiComponent.java similarity index 94% rename from src/main/java/noppes/npcs/scripted/interfaces/ICustomGuiComponent.java rename to src/main/java/noppes/npcs/scripted/interfaces/gui/ICustomGuiComponent.java index d0294878f..b321851fc 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ICustomGuiComponent.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/gui/ICustomGuiComponent.java @@ -3,7 +3,7 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.gui; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.scripted.gui.ScriptGuiComponent; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IItemSlot.java b/src/main/java/noppes/npcs/scripted/interfaces/gui/IItemSlot.java similarity index 76% rename from src/main/java/noppes/npcs/scripted/interfaces/IItemSlot.java rename to src/main/java/noppes/npcs/scripted/interfaces/gui/IItemSlot.java index 8fbca6779..7a7030a9c 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IItemSlot.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/gui/IItemSlot.java @@ -3,9 +3,10 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.gui; import net.minecraft.inventory.Slot; +import noppes.npcs.scripted.interfaces.item.IItemStack; public interface IItemSlot extends ICustomGuiComponent { boolean hasStack(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ILabel.java b/src/main/java/noppes/npcs/scripted/interfaces/gui/ILabel.java similarity index 90% rename from src/main/java/noppes/npcs/scripted/interfaces/ILabel.java rename to src/main/java/noppes/npcs/scripted/interfaces/gui/ILabel.java index 7fab012d7..bbee120ab 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ILabel.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/gui/ILabel.java @@ -3,7 +3,7 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.gui; public interface ILabel extends ICustomGuiComponent { String getText(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ILine.java b/src/main/java/noppes/npcs/scripted/interfaces/gui/ILine.java similarity index 86% rename from src/main/java/noppes/npcs/scripted/interfaces/ILine.java rename to src/main/java/noppes/npcs/scripted/interfaces/gui/ILine.java index 2ea987d5c..9fd13c47b 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ILine.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/gui/ILine.java @@ -1,4 +1,4 @@ -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.gui; public interface ILine extends ICustomGuiComponent { int getX1(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IScroll.java b/src/main/java/noppes/npcs/scripted/interfaces/gui/IScroll.java similarity index 91% rename from src/main/java/noppes/npcs/scripted/interfaces/IScroll.java rename to src/main/java/noppes/npcs/scripted/interfaces/gui/IScroll.java index 3f1a76fd2..76951d23b 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IScroll.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/gui/IScroll.java @@ -3,7 +3,7 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.gui; public interface IScroll extends ICustomGuiComponent { int getWidth(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ITextField.java b/src/main/java/noppes/npcs/scripted/interfaces/gui/ITextField.java similarity index 87% rename from src/main/java/noppes/npcs/scripted/interfaces/ITextField.java rename to src/main/java/noppes/npcs/scripted/interfaces/gui/ITextField.java index 88c3cca63..1ffb6e1a2 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ITextField.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/gui/ITextField.java @@ -3,7 +3,7 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.gui; public interface ITextField extends ICustomGuiComponent { int getWidth(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ITexturedRect.java b/src/main/java/noppes/npcs/scripted/interfaces/gui/ITexturedRect.java similarity index 91% rename from src/main/java/noppes/npcs/scripted/interfaces/ITexturedRect.java rename to src/main/java/noppes/npcs/scripted/interfaces/gui/ITexturedRect.java index 2d4c88cba..19b51c6dd 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ITexturedRect.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/gui/ITexturedRect.java @@ -3,7 +3,7 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.gui; public interface ITexturedRect extends ICustomGuiComponent { String getTexture(); diff --git a/src/main/java/noppes/npcs/scripted/handler/ICloneHandler.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/ICloneHandler.java similarity index 80% rename from src/main/java/noppes/npcs/scripted/handler/ICloneHandler.java rename to src/main/java/noppes/npcs/scripted/interfaces/handler/ICloneHandler.java index 177d1af2a..bd8c38683 100644 --- a/src/main/java/noppes/npcs/scripted/handler/ICloneHandler.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/ICloneHandler.java @@ -3,10 +3,10 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.handler; +package noppes.npcs.scripted.interfaces.handler; import noppes.npcs.scripted.interfaces.IWorld; -import noppes.npcs.scripted.interfaces.IEntity; +import noppes.npcs.scripted.interfaces.entity.IEntity; public interface ICloneHandler { IEntity spawn(double var1, double var3, double var5, int var7, String var8, IWorld var9); diff --git a/src/main/java/noppes/npcs/scripted/handler/IDialogHandler.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/IDialogHandler.java similarity index 56% rename from src/main/java/noppes/npcs/scripted/handler/IDialogHandler.java rename to src/main/java/noppes/npcs/scripted/interfaces/handler/IDialogHandler.java index e7df6bd60..4df7c9e97 100644 --- a/src/main/java/noppes/npcs/scripted/handler/IDialogHandler.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/IDialogHandler.java @@ -3,10 +3,10 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.handler; +package noppes.npcs.scripted.interfaces.handler; -import noppes.npcs.scripted.handler.data.IDialog; -import noppes.npcs.scripted.handler.data.IDialogCategory; +import noppes.npcs.scripted.interfaces.handler.data.IDialog; +import noppes.npcs.scripted.interfaces.handler.data.IDialogCategory; import java.util.List; diff --git a/src/main/java/noppes/npcs/scripted/handler/IFactionHandler.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/IFactionHandler.java similarity index 73% rename from src/main/java/noppes/npcs/scripted/handler/IFactionHandler.java rename to src/main/java/noppes/npcs/scripted/interfaces/handler/IFactionHandler.java index fededa2c0..1cbc59619 100644 --- a/src/main/java/noppes/npcs/scripted/handler/IFactionHandler.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/IFactionHandler.java @@ -3,9 +3,9 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.handler; +package noppes.npcs.scripted.interfaces.handler; -import noppes.npcs.scripted.handler.data.IFaction; +import noppes.npcs.scripted.interfaces.handler.data.IFaction; import java.util.List; diff --git a/src/main/java/noppes/npcs/scripted/handler/IQuestHandler.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/IQuestHandler.java similarity index 56% rename from src/main/java/noppes/npcs/scripted/handler/IQuestHandler.java rename to src/main/java/noppes/npcs/scripted/interfaces/handler/IQuestHandler.java index f10c53174..0fc4fae94 100644 --- a/src/main/java/noppes/npcs/scripted/handler/IQuestHandler.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/IQuestHandler.java @@ -3,10 +3,10 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.handler; +package noppes.npcs.scripted.interfaces.handler; -import noppes.npcs.scripted.handler.data.IQuest; -import noppes.npcs.scripted.handler.data.IQuestCategory; +import noppes.npcs.scripted.interfaces.handler.data.IQuest; +import noppes.npcs.scripted.interfaces.handler.data.IQuestCategory; import java.util.List; diff --git a/src/main/java/noppes/npcs/scripted/handler/IRecipeHandler.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/IRecipeHandler.java similarity index 81% rename from src/main/java/noppes/npcs/scripted/handler/IRecipeHandler.java rename to src/main/java/noppes/npcs/scripted/interfaces/handler/IRecipeHandler.java index 6c13bed57..fad5ca5e9 100644 --- a/src/main/java/noppes/npcs/scripted/handler/IRecipeHandler.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/IRecipeHandler.java @@ -3,11 +3,11 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.handler; +package noppes.npcs.scripted.interfaces.handler; import java.util.List; import net.minecraft.item.ItemStack; -import noppes.npcs.scripted.handler.data.IRecipe; +import noppes.npcs.scripted.interfaces.handler.data.IRecipe; public interface IRecipeHandler { List getGlobalList(); diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IAvailability.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IAvailability.java similarity index 85% rename from src/main/java/noppes/npcs/scripted/handler/data/IAvailability.java rename to src/main/java/noppes/npcs/scripted/interfaces/handler/data/IAvailability.java index 3bcb99b07..9408d5326 100644 --- a/src/main/java/noppes/npcs/scripted/handler/data/IAvailability.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IAvailability.java @@ -3,9 +3,9 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.handler.data; +package noppes.npcs.scripted.interfaces.handler.data; -import noppes.npcs.scripted.interfaces.IPlayer; +import noppes.npcs.scripted.interfaces.entity.IPlayer; public interface IAvailability { boolean isAvailable(IPlayer var1); diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IDialog.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IDialog.java similarity index 94% rename from src/main/java/noppes/npcs/scripted/handler/data/IDialog.java rename to src/main/java/noppes/npcs/scripted/interfaces/handler/data/IDialog.java index e45e978aa..e7e5bb6cc 100644 --- a/src/main/java/noppes/npcs/scripted/handler/data/IDialog.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IDialog.java @@ -3,7 +3,7 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.handler.data; +package noppes.npcs.scripted.interfaces.handler.data; import java.util.List; diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IDialogCategory.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IDialogCategory.java similarity index 81% rename from src/main/java/noppes/npcs/scripted/handler/data/IDialogCategory.java rename to src/main/java/noppes/npcs/scripted/interfaces/handler/data/IDialogCategory.java index e70ab4848..eaac2e7c3 100644 --- a/src/main/java/noppes/npcs/scripted/handler/data/IDialogCategory.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IDialogCategory.java @@ -3,7 +3,7 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.handler.data; +package noppes.npcs.scripted.interfaces.handler.data; import java.util.List; diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IDialogOption.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IDialogOption.java similarity index 79% rename from src/main/java/noppes/npcs/scripted/handler/data/IDialogOption.java rename to src/main/java/noppes/npcs/scripted/interfaces/handler/data/IDialogOption.java index 83356b44a..2ec037413 100644 --- a/src/main/java/noppes/npcs/scripted/handler/data/IDialogOption.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IDialogOption.java @@ -3,7 +3,7 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.handler.data; +package noppes.npcs.scripted.interfaces.handler.data; public interface IDialogOption { int getSlot(); diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IFaction.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IFaction.java similarity index 80% rename from src/main/java/noppes/npcs/scripted/handler/data/IFaction.java rename to src/main/java/noppes/npcs/scripted/interfaces/handler/data/IFaction.java index e46db9f5a..18e6f5a60 100644 --- a/src/main/java/noppes/npcs/scripted/handler/data/IFaction.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IFaction.java @@ -3,10 +3,10 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.handler.data; +package noppes.npcs.scripted.interfaces.handler.data; -import noppes.npcs.scripted.interfaces.ICustomNpc; -import noppes.npcs.scripted.interfaces.IPlayer; +import noppes.npcs.scripted.interfaces.entity.ICustomNpc; +import noppes.npcs.scripted.interfaces.entity.IPlayer; public interface IFaction { int getId(); diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IQuest.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuest.java similarity index 87% rename from src/main/java/noppes/npcs/scripted/handler/data/IQuest.java rename to src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuest.java index bfd640ec1..e23a2c162 100644 --- a/src/main/java/noppes/npcs/scripted/handler/data/IQuest.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuest.java @@ -3,10 +3,10 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.handler.data; +package noppes.npcs.scripted.interfaces.handler.data; import noppes.npcs.scripted.interfaces.IContainer; -import noppes.npcs.scripted.interfaces.IPlayer; +import noppes.npcs.scripted.interfaces.entity.IPlayer; public interface IQuest { int getId(); diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IQuestCategory.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestCategory.java similarity index 81% rename from src/main/java/noppes/npcs/scripted/handler/data/IQuestCategory.java rename to src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestCategory.java index 356afb758..40cf656f8 100644 --- a/src/main/java/noppes/npcs/scripted/handler/data/IQuestCategory.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestCategory.java @@ -3,7 +3,7 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.handler.data; +package noppes.npcs.scripted.interfaces.handler.data; import java.util.List; diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IQuestDialog.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestDialog.java similarity index 52% rename from src/main/java/noppes/npcs/scripted/handler/data/IQuestDialog.java rename to src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestDialog.java index 1e285efc0..894300747 100644 --- a/src/main/java/noppes/npcs/scripted/handler/data/IQuestDialog.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestDialog.java @@ -1,4 +1,4 @@ -package noppes.npcs.scripted.handler.data; +package noppes.npcs.scripted.interfaces.handler.data; public interface IQuestDialog extends IQuestInterface { } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestInterface.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestInterface.java new file mode 100644 index 000000000..2ce6f31d4 --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestInterface.java @@ -0,0 +1,4 @@ +package noppes.npcs.scripted.interfaces.handler.data; + +public interface IQuestInterface { +} diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IQuestItem.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestItem.java similarity index 83% rename from src/main/java/noppes/npcs/scripted/handler/data/IQuestItem.java rename to src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestItem.java index 7adca2254..deeb118d0 100644 --- a/src/main/java/noppes/npcs/scripted/handler/data/IQuestItem.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestItem.java @@ -1,4 +1,4 @@ -package noppes.npcs.scripted.handler.data; +package noppes.npcs.scripted.interfaces.handler.data; public interface IQuestItem extends IQuestInterface { void setLeaveItems(boolean leaveItems); diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IQuestKill.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestKill.java similarity index 68% rename from src/main/java/noppes/npcs/scripted/handler/data/IQuestKill.java rename to src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestKill.java index 7193f1aa8..c8e9e820f 100644 --- a/src/main/java/noppes/npcs/scripted/handler/data/IQuestKill.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestKill.java @@ -1,4 +1,4 @@ -package noppes.npcs.scripted.handler.data; +package noppes.npcs.scripted.interfaces.handler.data; public interface IQuestKill extends IQuestInterface { void setTargetType(int type); diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IQuestLocation.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestLocation.java similarity index 82% rename from src/main/java/noppes/npcs/scripted/handler/data/IQuestLocation.java rename to src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestLocation.java index 7496b81ba..dde45eaf9 100644 --- a/src/main/java/noppes/npcs/scripted/handler/data/IQuestLocation.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestLocation.java @@ -1,4 +1,4 @@ -package noppes.npcs.scripted.handler.data; +package noppes.npcs.scripted.interfaces.handler.data; public interface IQuestLocation extends IQuestInterface { void setLocation1(String loc1); diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IQuestObjective.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestObjective.java similarity index 83% rename from src/main/java/noppes/npcs/scripted/handler/data/IQuestObjective.java rename to src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestObjective.java index 5db05a027..24202df62 100644 --- a/src/main/java/noppes/npcs/scripted/handler/data/IQuestObjective.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IQuestObjective.java @@ -3,7 +3,7 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.handler.data; +package noppes.npcs.scripted.interfaces.handler.data; public interface IQuestObjective { int getProgress(); diff --git a/src/main/java/noppes/npcs/scripted/handler/data/IRecipe.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IRecipe.java similarity index 90% rename from src/main/java/noppes/npcs/scripted/handler/data/IRecipe.java rename to src/main/java/noppes/npcs/scripted/interfaces/handler/data/IRecipe.java index dd799c149..6fb1676e0 100644 --- a/src/main/java/noppes/npcs/scripted/handler/data/IRecipe.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/data/IRecipe.java @@ -3,7 +3,7 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.handler.data; +package noppes.npcs.scripted.interfaces.handler.data; import net.minecraft.item.ItemStack; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ICustomItem.java b/src/main/java/noppes/npcs/scripted/interfaces/item/ICustomItem.java similarity index 95% rename from src/main/java/noppes/npcs/scripted/interfaces/ICustomItem.java rename to src/main/java/noppes/npcs/scripted/interfaces/item/ICustomItem.java index 188471230..9ee43e389 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ICustomItem.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/item/ICustomItem.java @@ -1,6 +1,4 @@ -package noppes.npcs.scripted.interfaces; - -import net.minecraft.nbt.NBTTagCompound; +package noppes.npcs.scripted.interfaces.item; public interface ICustomItem extends IItemStack { String getTexture(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IItemStack.java b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemStack.java similarity index 97% rename from src/main/java/noppes/npcs/scripted/interfaces/IItemStack.java rename to src/main/java/noppes/npcs/scripted/interfaces/item/IItemStack.java index 0a491382e..917fd877d 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IItemStack.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemStack.java @@ -1,4 +1,4 @@ -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.item; import com.google.common.collect.Multimap; import net.minecraft.entity.ai.attributes.AttributeModifier; @@ -6,6 +6,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; +import noppes.npcs.scripted.interfaces.INbt; import java.util.ArrayList; import java.util.Iterator; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ICustomOverlay.java b/src/main/java/noppes/npcs/scripted/interfaces/overlay/ICustomOverlay.java similarity index 91% rename from src/main/java/noppes/npcs/scripted/interfaces/ICustomOverlay.java rename to src/main/java/noppes/npcs/scripted/interfaces/overlay/ICustomOverlay.java index 05d0cf04f..b1394ddd8 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ICustomOverlay.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/overlay/ICustomOverlay.java @@ -1,6 +1,8 @@ -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.overlay; import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.scripted.interfaces.entity.IPlayer; + import java.util.List; public interface ICustomOverlay { diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ICustomOverlayComponent.java b/src/main/java/noppes/npcs/scripted/interfaces/overlay/ICustomOverlayComponent.java similarity index 93% rename from src/main/java/noppes/npcs/scripted/interfaces/ICustomOverlayComponent.java rename to src/main/java/noppes/npcs/scripted/interfaces/overlay/ICustomOverlayComponent.java index 1fe1a2cdd..d1c0a12aa 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ICustomOverlayComponent.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/overlay/ICustomOverlayComponent.java @@ -1,4 +1,4 @@ -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.overlay; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.scripted.overlay.ScriptOverlayComponent; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IOverlayLabel.java b/src/main/java/noppes/npcs/scripted/interfaces/overlay/IOverlayLabel.java similarity index 87% rename from src/main/java/noppes/npcs/scripted/interfaces/IOverlayLabel.java rename to src/main/java/noppes/npcs/scripted/interfaces/overlay/IOverlayLabel.java index 1032fad5f..f44d283f5 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IOverlayLabel.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/overlay/IOverlayLabel.java @@ -1,4 +1,4 @@ -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.overlay; public interface IOverlayLabel extends ICustomOverlayComponent { String getText(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IOverlayLine.java b/src/main/java/noppes/npcs/scripted/interfaces/overlay/IOverlayLine.java similarity index 75% rename from src/main/java/noppes/npcs/scripted/interfaces/IOverlayLine.java rename to src/main/java/noppes/npcs/scripted/interfaces/overlay/IOverlayLine.java index 517eb7e51..b6b4a4f0e 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IOverlayLine.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/overlay/IOverlayLine.java @@ -1,6 +1,4 @@ -package noppes.npcs.scripted.interfaces; - -import noppes.npcs.scripted.overlay.ScriptOverlayLine; +package noppes.npcs.scripted.interfaces.overlay; public interface IOverlayLine extends ICustomOverlayComponent { int getX1(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IOverlayTexturedRect.java b/src/main/java/noppes/npcs/scripted/interfaces/overlay/IOverlayTexturedRect.java similarity index 89% rename from src/main/java/noppes/npcs/scripted/interfaces/IOverlayTexturedRect.java rename to src/main/java/noppes/npcs/scripted/interfaces/overlay/IOverlayTexturedRect.java index bd5b6a2d6..7d2f8275a 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IOverlayTexturedRect.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/overlay/IOverlayTexturedRect.java @@ -1,4 +1,4 @@ -package noppes.npcs.scripted.interfaces; +package noppes.npcs.scripted.interfaces.overlay; public interface IOverlayTexturedRect extends ICustomOverlayComponent { String getTexture(); diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java index b3233840f..721e3b694 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java @@ -10,7 +10,7 @@ import noppes.npcs.controllers.IScriptHandler; import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.controllers.ScriptController; import noppes.npcs.scripted.CustomNPCsException; -import noppes.npcs.scripted.interfaces.ICustomItem; +import noppes.npcs.scripted.interfaces.item.ICustomItem; import java.util.*; diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java index 8c735e1b5..09909fbfa 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java @@ -21,7 +21,7 @@ import net.minecraft.nbt.NBTTagString; import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.ScriptNbt; -import noppes.npcs.scripted.interfaces.IItemStack; +import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.INbt; public class ScriptItemStack implements IItemStack { diff --git a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java index 58eb082d3..6cd2c5293 100644 --- a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java +++ b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java @@ -4,14 +4,9 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.controllers.CustomGuiController; -import noppes.npcs.controllers.ScriptController; -import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.scripted.entity.ScriptPlayer; -import noppes.npcs.scripted.gui.ScriptGuiComponent; -import noppes.npcs.scripted.gui.ScriptGuiItemSlot; -import noppes.npcs.scripted.gui.ScriptGuiLabel; -import noppes.npcs.scripted.gui.ScriptGuiLine; -import noppes.npcs.scripted.interfaces.*; +import noppes.npcs.scripted.interfaces.entity.IPlayer; +import noppes.npcs.scripted.interfaces.overlay.*; import java.util.ArrayList; import java.util.Iterator; diff --git a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayComponent.java b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayComponent.java index 88aa3f396..737f13f52 100644 --- a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayComponent.java +++ b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayComponent.java @@ -1,12 +1,7 @@ package noppes.npcs.scripted.overlay; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagString; -import noppes.npcs.scripted.gui.*; -import noppes.npcs.scripted.interfaces.ICustomGuiComponent; -import noppes.npcs.scripted.interfaces.ICustomOverlayComponent; -import noppes.npcs.scripted.interfaces.IOverlayTexturedRect; +import noppes.npcs.scripted.interfaces.overlay.ICustomOverlayComponent; public abstract class ScriptOverlayComponent implements ICustomOverlayComponent { int id; diff --git a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLabel.java b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLabel.java index 3e2e041ad..cc238ae1d 100644 --- a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLabel.java +++ b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLabel.java @@ -1,9 +1,7 @@ package noppes.npcs.scripted.overlay; import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.scripted.gui.ScriptGuiComponent; -import noppes.npcs.scripted.interfaces.ILabel; -import noppes.npcs.scripted.interfaces.IOverlayLabel; +import noppes.npcs.scripted.interfaces.overlay.IOverlayLabel; public class ScriptOverlayLabel extends ScriptOverlayComponent implements IOverlayLabel { String label; diff --git a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLine.java b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLine.java index 07590298c..c5c24b26b 100644 --- a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLine.java +++ b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayLine.java @@ -1,8 +1,7 @@ package noppes.npcs.scripted.overlay; import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.scripted.gui.ScriptGuiComponent; -import noppes.npcs.scripted.interfaces.IOverlayLine; +import noppes.npcs.scripted.interfaces.overlay.IOverlayLine; public class ScriptOverlayLine extends ScriptOverlayComponent implements IOverlayLine { int x1; diff --git a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayTexturedRect.java b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayTexturedRect.java index 85d0fa155..b7eaff2f0 100644 --- a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayTexturedRect.java +++ b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlayTexturedRect.java @@ -1,10 +1,7 @@ package noppes.npcs.scripted.overlay; import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.scripted.gui.ScriptGuiComponent; -import noppes.npcs.scripted.interfaces.IOverlayLabel; -import noppes.npcs.scripted.interfaces.IOverlayTexturedRect; -import noppes.npcs.scripted.interfaces.ITexturedRect; +import noppes.npcs.scripted.interfaces.overlay.IOverlayTexturedRect; public class ScriptOverlayTexturedRect extends ScriptOverlayComponent implements IOverlayTexturedRect { int width; diff --git a/src/main/java/noppes/npcs/scripted/wrapper/ScriptDamageSource.java b/src/main/java/noppes/npcs/scripted/wrapper/ScriptDamageSource.java index 0f8fe38ac..15d89bb17 100644 --- a/src/main/java/noppes/npcs/scripted/wrapper/ScriptDamageSource.java +++ b/src/main/java/noppes/npcs/scripted/wrapper/ScriptDamageSource.java @@ -8,8 +8,7 @@ package noppes.npcs.scripted.wrapper; import net.minecraft.util.DamageSource; import noppes.npcs.controllers.ScriptController; import noppes.npcs.scripted.interfaces.IDamageSource; -import noppes.npcs.scripted.NpcAPI; -import noppes.npcs.scripted.interfaces.IEntity; +import noppes.npcs.scripted.interfaces.entity.IEntity; public class ScriptDamageSource implements IDamageSource { private DamageSource source; diff --git a/src/main/java/noppes/npcs/scripted/wrapper/WrapperEntityData.java b/src/main/java/noppes/npcs/scripted/wrapper/WrapperEntityData.java index 641e211e2..71a2a3f5e 100644 --- a/src/main/java/noppes/npcs/scripted/wrapper/WrapperEntityData.java +++ b/src/main/java/noppes/npcs/scripted/wrapper/WrapperEntityData.java @@ -15,7 +15,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.ResourceLocation; import noppes.npcs.controllers.PixelmonHelper; import noppes.npcs.scripted.entity.*; -import noppes.npcs.scripted.interfaces.IEntity; +import noppes.npcs.scripted.interfaces.entity.IEntity; public class WrapperEntityData{ public IEntity base; diff --git a/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java b/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java index 48ab68fc1..a83d1f353 100644 --- a/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java @@ -40,8 +40,14 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.ScriptContainer; import noppes.npcs.scripted.entity.*; import noppes.npcs.scripted.gui.ScriptGui; -import noppes.npcs.scripted.handler.*; +import noppes.npcs.scripted.interfaces.handler.*; import noppes.npcs.scripted.interfaces.*; +import noppes.npcs.scripted.interfaces.entity.ICustomNpc; +import noppes.npcs.scripted.interfaces.entity.IEntity; +import noppes.npcs.scripted.interfaces.gui.ICustomGui; +import noppes.npcs.scripted.interfaces.item.ICustomItem; +import noppes.npcs.scripted.interfaces.item.IItemStack; +import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay; import noppes.npcs.scripted.item.ScriptCustomItem; import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.overlay.ScriptOverlay; From 6896cec4177397b1a4fb7b832ef9511d26d89d58 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 11 May 2022 17:12:48 -0500 Subject: [PATCH 31/75] Every function in API classes that calls the main API class now calls the loaded API wrapper, renamed to NpcAPI, instead of the abstract class, renamed to AbstractNpcAPI. --- src/main/java/noppes/npcs/CustomNpcs.java | 6 +- src/main/java/noppes/npcs/DataScript.java | 5 +- src/main/java/noppes/npcs/EventHooks.java | 142 +++++++++--------- .../java/noppes/npcs/NoppesUtilPlayer.java | 2 +- .../java/noppes/npcs/PacketHandlerServer.java | 1 - .../noppes/npcs/ScriptItemEventHandler.java | 3 +- .../noppes/npcs/ScriptPlayerEventHandler.java | 2 +- .../npcs/client/PacketHandlerClient.java | 2 - .../npcs/controllers/CustomGuiController.java | 13 +- .../java/noppes/npcs/controllers/Quest.java | 2 +- .../npcs/controllers/ScriptContainer.java | 4 +- .../controllers/data/ForgeDataScript.java | 3 - .../java/noppes/npcs/items/ItemScripted.java | 2 +- .../{NpcAPI.java => AbstractNpcAPI.java} | 12 +- .../noppes/npcs/scripted/ScriptBlock.java | 1 + .../noppes/npcs/scripted/ScriptContainer.java | 1 + .../npcs/scripted/ScriptTileEntity.java | 2 +- .../noppes/npcs/scripted/ScriptWorld.java | 4 +- .../npcs/scripted/entity/ScriptDBCPlayer.java | 6 +- .../npcs/scripted/entity/ScriptEntity.java | 3 +- .../scripted/entity/ScriptLivingBase.java | 6 +- .../npcs/scripted/entity/ScriptNpc.java | 12 +- .../npcs/scripted/entity/ScriptPlayer.java | 4 +- .../npcs/scripted/event/CustomNPCsEvent.java | 4 +- .../noppes/npcs/scripted/event/ItemEvent.java | 28 ++-- .../noppes/npcs/scripted/event/NpcEvent.java | 2 +- .../npcs/scripted/event/PlayerEvent.java | 2 +- .../npcs/scripted/gui/ScriptGuiItemSlot.java | 2 +- .../npcs/scripted/interfaces/IBlock.java | 2 - .../npcs/scripted/interfaces/ITileEntity.java | 4 - .../scripted/interfaces/entity/IEntity.java | 4 - .../scripted/interfaces/item/IItemArmor.java | 7 + .../scripted/interfaces/item/IItemBlock.java | 5 + .../scripted/interfaces/item/IItemBook.java | 15 ++ .../{ICustomItem.java => IItemCustom.java} | 2 +- .../npcs/scripted/item/ScriptCustomItem.java | 4 +- .../npcs/scripted/item/ScriptItemArmor.java | 19 +++ .../npcs/scripted/item/ScriptItemBlock.java | 15 ++ .../npcs/scripted/item/ScriptItemBook.java | 35 +++++ .../npcs/scripted/item/ScriptItemStack.java | 2 +- .../{WrapperNpcAPI.java => NpcAPI.java} | 34 ++--- 41 files changed, 252 insertions(+), 172 deletions(-) rename src/main/java/noppes/npcs/scripted/{NpcAPI.java => AbstractNpcAPI.java} (90%) create mode 100644 src/main/java/noppes/npcs/scripted/interfaces/item/IItemArmor.java create mode 100644 src/main/java/noppes/npcs/scripted/interfaces/item/IItemBlock.java create mode 100644 src/main/java/noppes/npcs/scripted/interfaces/item/IItemBook.java rename src/main/java/noppes/npcs/scripted/interfaces/item/{ICustomItem.java => IItemCustom.java} (97%) create mode 100644 src/main/java/noppes/npcs/scripted/item/ScriptItemArmor.java create mode 100644 src/main/java/noppes/npcs/scripted/item/ScriptItemBlock.java create mode 100644 src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java rename src/main/java/noppes/npcs/scripted/wrapper/{WrapperNpcAPI.java => NpcAPI.java} (97%) diff --git a/src/main/java/noppes/npcs/CustomNpcs.java b/src/main/java/noppes/npcs/CustomNpcs.java index a14226b80..9b13a1ff2 100644 --- a/src/main/java/noppes/npcs/CustomNpcs.java +++ b/src/main/java/noppes/npcs/CustomNpcs.java @@ -1,6 +1,5 @@ package noppes.npcs; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; @@ -27,7 +26,8 @@ import noppes.npcs.controllers.*; import noppes.npcs.enchants.EnchantInterface; import noppes.npcs.entity.*; import noppes.npcs.entity.old.*; -import noppes.npcs.scripted.wrapper.WrapperNpcAPI; +import noppes.npcs.scripted.wrapper.NpcAPI; + import java.io.File; import java.util.Set; @@ -257,7 +257,7 @@ public class CustomNpcs { ScriptController.Instance.loadNPCScripts(); ScriptController.Instance.loadPlayerScripts(); ScriptController.HasStart = false; - WrapperNpcAPI.clearCache(); + NpcAPI.clearCache(); Set names = Block.blockRegistry.getKeys(); for(String name : names){ diff --git a/src/main/java/noppes/npcs/DataScript.java b/src/main/java/noppes/npcs/DataScript.java index 8e8c70cc3..eb85f950b 100644 --- a/src/main/java/noppes/npcs/DataScript.java +++ b/src/main/java/noppes/npcs/DataScript.java @@ -15,7 +15,6 @@ import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.controllers.IScriptHandler; import noppes.npcs.controllers.ScriptController; import noppes.npcs.entity.EntityNPCInterface; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.event.ScriptEvent; import noppes.npcs.scripted.entity.ScriptNpc; import noppes.npcs.scripted.ScriptWorld; @@ -24,7 +23,7 @@ import noppes.npcs.scripted.constants.JobType; import noppes.npcs.scripted.constants.RoleType; import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import noppes.npcs.scripted.interfaces.IWorld; -import noppes.npcs.scripted.wrapper.WrapperNpcAPI; +import noppes.npcs.scripted.wrapper.NpcAPI; public class DataScript implements IScriptHandler { public List scripts = new ArrayList(); @@ -134,7 +133,7 @@ public class DataScript implements IScriptHandler { ScriptEvent result = (ScriptEvent) engine.get("event"); if(result == null) engine.put("event", result = new ScriptEvent()); - engine.put("API", new WrapperNpcAPI()); + engine.put("API", new NpcAPI()); engine.put("EntityType", entities); engine.put("RoleType", roles); engine.put("JobType", jobs); diff --git a/src/main/java/noppes/npcs/EventHooks.java b/src/main/java/noppes/npcs/EventHooks.java index 407b33acb..4bb574437 100644 --- a/src/main/java/noppes/npcs/EventHooks.java +++ b/src/main/java/noppes/npcs/EventHooks.java @@ -41,7 +41,7 @@ import noppes.npcs.scripted.interfaces.gui.ICustomGui; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptCustomItem; import noppes.npcs.scripted.item.ScriptItemStack; -import noppes.npcs.scripted.wrapper.WrapperNpcAPI; +import noppes.npcs.scripted.wrapper.NpcAPI; import noppes.npcs.constants.EnumScriptType; import org.apache.commons.lang3.StringUtils; @@ -55,7 +55,7 @@ public class EventHooks { if (!handler.isClient()) { ItemEvent.InitEvent event = new ItemEvent.InitEvent(handler); handler.callScript(EnumScriptType.INIT, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } } @@ -63,60 +63,60 @@ public class EventHooks { if (!handler.isClient()) { ItemEvent.UpdateEvent event = new ItemEvent.UpdateEvent(handler, ScriptController.Instance.getScriptForEntity(player)); handler.callScript(EnumScriptType.TICK, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } } public static boolean onScriptItemTossed(ScriptCustomItem handler, EntityPlayer player, EntityItem entity) { ItemEvent.TossedEvent event = new ItemEvent.TossedEvent(handler, (ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), ScriptController.Instance.getScriptForEntity(entity)); handler.callScript(EnumScriptType.TOSSED, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onScriptItemPickedUp(ScriptCustomItem handler, EntityPlayer player) { ItemEvent.PickedUpEvent event = new ItemEvent.PickedUpEvent(handler, (ScriptPlayer)ScriptController.Instance.getScriptForEntity(player)); handler.callScript(EnumScriptType.PICKEDUP, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onScriptItemSpawn(ScriptCustomItem handler, EntityItem entity) { ItemEvent.SpawnEvent event = new ItemEvent.SpawnEvent(handler, ScriptController.Instance.getScriptForEntity(entity)); handler.callScript(EnumScriptType.SPAWN, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onScriptItemInteract(ScriptCustomItem handler, noppes.npcs.scripted.event.ItemEvent.InteractEvent event) { handler.callScript(EnumScriptType.INTERACT, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onScriptItemAttack(ScriptCustomItem handler, noppes.npcs.scripted.event.ItemEvent.AttackEvent event) { handler.callScript(EnumScriptType.ATTACK, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onStartUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) { ItemEvent.StartUsingItem event = new ItemEvent.StartUsingItem(handler, player, duration); handler.callScript(EnumScriptType.START_USING_ITEM, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) { ItemEvent.UsingItem event = new ItemEvent.UsingItem(handler, player, duration); handler.callScript(EnumScriptType.USING_ITEM, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onStopUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) { ItemEvent.StopUsingItem event = new ItemEvent.StopUsingItem(handler, player, duration); handler.callScript(EnumScriptType.STOP_USING_ITEM, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onFinishUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) { ItemEvent.FinishUsingItem event = new ItemEvent.FinishUsingItem(handler, player, duration); handler.callScript(EnumScriptType.FINISH_USING_ITEM, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static void onNPCInit(EntityNPCInterface npc) { @@ -126,7 +126,7 @@ public class EventHooks { noppes.npcs.scripted.event.NpcEvent.InitEvent event = new noppes.npcs.scripted.event.NpcEvent.InitEvent(npc.wrappedNPC); ScriptController.Instance.npcScripts.callScript(EnumScriptType.INIT, event); npc.script.callScript(EnumScriptType.INIT); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onNPCUpdate(EntityNPCInterface npc) { @@ -136,7 +136,7 @@ public class EventHooks { noppes.npcs.scripted.event.NpcEvent.UpdateEvent event = new noppes.npcs.scripted.event.NpcEvent.UpdateEvent(npc.wrappedNPC); ScriptController.Instance.npcScripts.callScript(EnumScriptType.TICK, event); npc.script.callScript(EnumScriptType.TICK); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onNPCDialog(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) { @@ -149,7 +149,7 @@ public class EventHooks { ScriptEventDialog npcEvent = new ScriptEventDialog(player,dialogId,optionId,dialog); npc.script.callScript(EnumScriptType.DIALOG, "event", npcEvent, "player", npcEvent.getPlayer(), "dialog", npcEvent.getDialogId(), "option", npcEvent.getOptionId(), "dialogObj", npcEvent.getDialog()); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onNPCDialogClosed(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) { @@ -162,7 +162,7 @@ public class EventHooks { ScriptEventDialog npcEvent = new ScriptEventDialog(player,dialogId,optionId,dialog); npc.script.callScript(EnumScriptType.DIALOG_CLOSE, "event", npcEvent, "player", npcEvent.getPlayer(), "dialog", npcEvent.getDialogId(), "option", npcEvent.getOptionId(), "dialogObj", npcEvent.getDialog()); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onNPCInteract(EntityNPCInterface npc, EntityPlayer player) { @@ -172,7 +172,7 @@ public class EventHooks { NpcEvent.InteractEvent event = new NpcEvent.InteractEvent(npc.wrappedNPC,player); ScriptController.Instance.npcScripts.callScript(EnumScriptType.INTERACT, event); boolean result = npc.script.callScript(EnumScriptType.INTERACT, "player", player); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); return result; } @@ -183,7 +183,7 @@ public class EventHooks { NpcEvent.MeleeAttackEvent event = new NpcEvent.MeleeAttackEvent(npc.wrappedNPC,damage,target); ScriptController.Instance.npcScripts.callScript(EnumScriptType.ATTACK_MELEE, event); boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", new ScriptEventAttack(damage,target,false), "target", target); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); return result; } @@ -194,7 +194,7 @@ public class EventHooks { NpcEvent.RangedLaunchedEvent event = new NpcEvent.RangedLaunchedEvent(npc.wrappedNPC,damage,target); ScriptController.Instance.npcScripts.callScript(EnumScriptType.RANGED_LAUNCHED, event); boolean result = npc.script.callScript(EnumScriptType.ATTACK, "event", new ScriptEventAttack(damage,target,true), "target", target); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); return result; } @@ -205,7 +205,7 @@ public class EventHooks { NpcEvent.KilledEntityEvent event = new NpcEvent.KilledEntityEvent(npc.wrappedNPC,entity); ScriptController.Instance.npcScripts.callScript(EnumScriptType.KILLS, event); npc.script.callScript(EnumScriptType.KILLS, "target", entity); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onNPCTarget(EntityNPCInterface npc, EntityLivingBase target){ @@ -215,7 +215,7 @@ public class EventHooks { NpcEvent.TargetEvent event = new NpcEvent.TargetEvent(npc.wrappedNPC,target); ScriptController.Instance.npcScripts.callScript(EnumScriptType.TARGET, event); boolean result = npc.script.callScript(EnumScriptType.TARGET, "event", new ScriptEventTarget(target)); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); return result; } @@ -226,7 +226,7 @@ public class EventHooks { NpcEvent.CollideEvent event = new NpcEvent.CollideEvent(npc.wrappedNPC,entity); ScriptController.Instance.npcScripts.callScript(EnumScriptType.COLLIDE, event); npc.script.callScript(EnumScriptType.COLLIDE, "entity", entity); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onNPCDamaged(EntityNPCInterface npc, Entity source, float damage, DamageSource damagesource, ScriptEventDamaged damagedEvent){ @@ -236,7 +236,7 @@ public class EventHooks { NpcEvent.DamagedEvent event = new NpcEvent.DamagedEvent(npc.wrappedNPC,source,damage,damagesource); ScriptController.Instance.npcScripts.callScript(EnumScriptType.DAMAGED, event); boolean result = npc.script.callScript(EnumScriptType.DAMAGED, "event", damagedEvent); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); return result; } @@ -247,7 +247,7 @@ public class EventHooks { NpcEvent.DiedEvent event = new NpcEvent.DiedEvent(npc.wrappedNPC,damagesource,entity); ScriptController.Instance.npcScripts.callScript(EnumScriptType.KILLED, event); boolean result = npc.script.callScript(EnumScriptType.KILLED, "event", killedEvent); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); return result; } @@ -259,48 +259,48 @@ public class EventHooks { ScriptEventTimer scriptEvent = new ScriptEventTimer(id); npc.script.callScript(EnumScriptType.TIMER, "event", scriptEvent); ScriptController.Instance.npcScripts.callScript(EnumScriptType.TIMER, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerInit(PlayerDataScript handler, ScriptPlayer player) { noppes.npcs.scripted.event.PlayerEvent.InitEvent event = new noppes.npcs.scripted.event.PlayerEvent.InitEvent(player); handler.callScript(EnumScriptType.INIT, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerTick(PlayerDataScript handler, ScriptPlayer player) { noppes.npcs.scripted.event.PlayerEvent.UpdateEvent event = new noppes.npcs.scripted.event.PlayerEvent.UpdateEvent(player); handler.callScript(EnumScriptType.TICK, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerInteract(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.InteractEvent event) { handler.callScript(EnumScriptType.INTERACT, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onStartUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){ PlayerEvent.StartUsingItem event = new PlayerEvent.StartUsingItem(player, item, duration); handler.callScript(EnumScriptType.START_USING_ITEM, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){ PlayerEvent.UsingItem event = new PlayerEvent.UsingItem(player, item, duration); handler.callScript(EnumScriptType.USING_ITEM, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onStopUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){ PlayerEvent.StopUsingItem event = new PlayerEvent.StopUsingItem(player, item, duration); handler.callScript(EnumScriptType.STOP_USING_ITEM, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static void onFinishUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){ PlayerEvent.FinishUsingItem event = new PlayerEvent.FinishUsingItem(player, item, duration); handler.callScript(EnumScriptType.FINISH_USING_ITEM, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerDropItems(PlayerDataScript handler, ScriptPlayer player, ArrayList entityItems) { @@ -309,178 +309,178 @@ public class EventHooks { DropEvent event = new DropEvent(player, items); handler.callScript(EnumScriptType.DROP, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static void onPlayerPickupXP(PlayerDataScript handler, ScriptPlayer player, EntityXPOrb orb) { PlayerEvent.PickupXPEvent event = new PlayerEvent.PickupXPEvent(player, orb); handler.callScript(EnumScriptType.PICKUP_XP, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerToss(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) { PlayerEvent.TossEvent event = new PlayerEvent.TossEvent(player, NpcAPI.Instance().getIItemStack(entityItem.getEntityItem())); handler.callScript(EnumScriptType.TOSS, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerPickUp(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) { PickUpEvent event = new PickUpEvent(player, new ScriptItemStack(entityItem.getEntityItem()));//NpcAPI.Instance().getIItemStack(entityItem.getEntityItem())); handler.callScript(EnumScriptType.PICKUP, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static void onPlayerContainerOpen(PlayerDataScript handler, ScriptPlayer player, Container container) { ContainerOpen event = new ContainerOpen(player, NpcAPI.Instance().getIContainer(container)); handler.callScript(EnumScriptType.CONTAINER_OPEN, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerUseHoe(PlayerDataScript handler, ScriptPlayer player, ItemStack hoe, int x, int y, int z) { noppes.npcs.scripted.event.PlayerEvent.UseHoe event = new noppes.npcs.scripted.event.PlayerEvent.UseHoe(player, hoe, x, y, z); handler.callScript(EnumScriptType.USE_HOE, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerSleep(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z) { noppes.npcs.scripted.event.PlayerEvent.Sleep event = new noppes.npcs.scripted.event.PlayerEvent.Sleep(player, x, y, z); handler.callScript(EnumScriptType.SLEEP, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerWakeUp(PlayerDataScript handler, ScriptPlayer player, boolean setSpawn) { noppes.npcs.scripted.event.PlayerEvent.WakeUp event = new noppes.npcs.scripted.event.PlayerEvent.WakeUp(player, setSpawn); handler.callScript(EnumScriptType.WAKE_UP, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerDeath(PlayerDataScript handler, ScriptPlayer player, DamageSource source, Entity entity) { noppes.npcs.scripted.event.PlayerEvent.DiedEvent event = new noppes.npcs.scripted.event.PlayerEvent.DiedEvent(player, source, entity); handler.callScript(EnumScriptType.KILLED, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerKills(PlayerDataScript handler, ScriptPlayer player, EntityLivingBase entityLiving) { noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent event = new noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent(player, entityLiving); handler.callScript(EnumScriptType.KILLS, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerDamaged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.DamagedEvent event) { handler.callScript(EnumScriptType.DAMAGED, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerLightning(PlayerDataScript handler, ScriptPlayer player) { PlayerEvent.LightningEvent event = new PlayerEvent.LightningEvent(player); handler.callScript(EnumScriptType.LIGHTNING, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerSound(PlayerDataScript handler, ScriptPlayer player, String name, float pitch, float volume) { PlayerEvent.SoundEvent event = new PlayerEvent.SoundEvent(player, name, pitch, volume); handler.callScript(EnumScriptType.PLAYSOUND, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static void onPlayerFall(PlayerDataScript handler, ScriptPlayer player, float distance) { PlayerEvent.FallEvent event = new PlayerEvent.FallEvent(player,distance); handler.callScript(EnumScriptType.FALL, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerJump(PlayerDataScript handler, ScriptPlayer player) { PlayerEvent.JumpEvent event = new PlayerEvent.JumpEvent(player); handler.callScript(EnumScriptType.JUMP, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerLogin(PlayerDataScript handler, ScriptPlayer player) { LoginEvent event = new LoginEvent(player); handler.callScript(EnumScriptType.LOGIN, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerAchievement(PlayerDataScript handler, ScriptPlayer player, String description) { PlayerEvent.Achievement event = new PlayerEvent.Achievement(player, description); handler.callScript(EnumScriptType.ACHIEVEMENT, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerFillBucket(PlayerDataScript handler, ScriptPlayer player, ItemStack current, ItemStack result) { PlayerEvent.FillBucket event = new PlayerEvent.FillBucket(player, current, result); handler.callScript(EnumScriptType.FILL_BUCKET, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerBonemeal(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z, World world) { PlayerEvent.Bonemeal event = new PlayerEvent.Bonemeal(player, x, y, z, world); handler.callScript(EnumScriptType.BONEMEAL, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerRespawn(PlayerDataScript handler, ScriptPlayer player) { PlayerEvent.RespawnEvent event = new PlayerEvent.RespawnEvent(player); handler.callScript(EnumScriptType.RESPAWN, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerLogout(PlayerDataScript handler, ScriptPlayer player) { LogoutEvent event = new LogoutEvent(player); handler.callScript(EnumScriptType.LOGOUT, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerChat(PlayerDataScript handler, ChatEvent event) { handler.callScript(EnumScriptType.CHAT, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerBowCharge(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent event) { handler.callScript(EnumScriptType.RANGED_CHARGE, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerRanged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent event) { handler.callScript(EnumScriptType.RANGED_LAUNCHED, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerDamagedEntity(PlayerDataScript handler, DamagedEntityEvent event) { handler.callScript(EnumScriptType.DAMAGED_ENTITY, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static void onPlayerChangeDim(PlayerDataScript handler, ScriptPlayer player, int fromDim, int toDim) { PlayerEvent.ChangedDimension event = new PlayerEvent.ChangedDimension(player, fromDim, toDim); handler.callScript(EnumScriptType.CHANGED_DIM, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerMouseClicked(EntityPlayerMP player, int button, int mouseWheel, boolean buttonDown) { PlayerDataScript handler = ScriptController.Instance.playerScripts; PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, mouseWheel, buttonDown); handler.callScript(EnumScriptType.MOUSE_CLICKED, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean buttonDown, int[] heldKeys) { PlayerDataScript handler = ScriptController.Instance.playerScripts; KeyPressedEvent event = new KeyPressedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown, heldKeys); handler.callScript(EnumScriptType.KEY_PRESSED, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onPlayerTimer(PlayerData data, int id) { PlayerDataScript handler = ScriptController.Instance.playerScripts; noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(data.player), id); handler.callScript(EnumScriptType.TIMER, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onPlayerBreak(PlayerDataScript handler, PlayerEvent.BreakEvent event) { handler.callScript(EnumScriptType.BREAK_BLOCK, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static void onForgeEntityEvent(EntityEvent event) { @@ -498,7 +498,7 @@ public class EventHooks { public static void onForgeInit(ForgeDataScript handler) { noppes.npcs.scripted.event.ForgeEvent.InitEvent event = new noppes.npcs.scripted.event.ForgeEvent.InitEvent(); handler.callScript("init", event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onForgeEvent(ForgeEvent ev, Event event) { @@ -512,7 +512,7 @@ public class EventHooks { } handler.callScript(eventName, event); - WrapperNpcAPI.EVENT_BUS.post(ev); + NpcAPI.EVENT_BUS.post(ev); if(event.isCancelable()) { event.setCanceled(ev.isCanceled()); } @@ -549,43 +549,43 @@ public class EventHooks { PlayerDataScript handler = ScriptController.Instance.playerScripts; QuestEvent.QuestCompletedEvent event = new QuestEvent.QuestCompletedEvent(new ScriptPlayer((EntityPlayerMP) player), quest); handler.callScript(EnumScriptType.QUEST_COMPLETED, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static boolean onQuestStarted(EntityPlayer player, Quest quest){ PlayerDataScript handler = ScriptController.Instance.playerScripts; QuestEvent.QuestStartEvent event = new QuestEvent.QuestStartEvent(new ScriptPlayer((EntityPlayerMP) player), quest); handler.callScript(EnumScriptType.QUEST_START, event); - return WrapperNpcAPI.EVENT_BUS.post(event); + return NpcAPI.EVENT_BUS.post(event); } public static void onQuestTurnedIn(QuestEvent.QuestTurnedInEvent event){ PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.QUEST_TURNIN, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onFactionPoints(FactionEvent.FactionPoints event){ PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.FACTION_POINTS, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onDialogOpen(DialogEvent.DialogOpen event){ PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.DIALOG_OPEN, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onDialogOption(DialogEvent.DialogOption event){ PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.DIALOG_OPTION, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onDialogClosed(DialogEvent.DialogClosed event){ PlayerDataScript handler = ScriptController.Instance.playerScripts; handler.callScript(EnumScriptType.DIALOG_CLOSE, event); - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } } \ No newline at end of file diff --git a/src/main/java/noppes/npcs/NoppesUtilPlayer.java b/src/main/java/noppes/npcs/NoppesUtilPlayer.java index 6e5101f6e..eb5066ecd 100644 --- a/src/main/java/noppes/npcs/NoppesUtilPlayer.java +++ b/src/main/java/noppes/npcs/NoppesUtilPlayer.java @@ -29,11 +29,11 @@ import noppes.npcs.controllers.*; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleFollower; import cpw.mods.fml.common.network.internal.FMLProxyPacket; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.event.DialogEvent; import noppes.npcs.scripted.event.QuestEvent; import noppes.npcs.scripted.interfaces.item.IItemStack; +import noppes.npcs.scripted.wrapper.NpcAPI; public class NoppesUtilPlayer { diff --git a/src/main/java/noppes/npcs/PacketHandlerServer.java b/src/main/java/noppes/npcs/PacketHandlerServer.java index d0bb72d25..18892ed2c 100644 --- a/src/main/java/noppes/npcs/PacketHandlerServer.java +++ b/src/main/java/noppes/npcs/PacketHandlerServer.java @@ -51,7 +51,6 @@ import noppes.npcs.roles.RoleTrader; import noppes.npcs.roles.RoleTransporter; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.gui.ScriptGui; import noppes.npcs.scripted.item.ScriptCustomItem; diff --git a/src/main/java/noppes/npcs/ScriptItemEventHandler.java b/src/main/java/noppes/npcs/ScriptItemEventHandler.java index 23d56811a..c460cb80c 100644 --- a/src/main/java/noppes/npcs/ScriptItemEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptItemEventHandler.java @@ -15,12 +15,13 @@ import net.minecraftforge.event.entity.player.PlayerUseItemEvent; import noppes.npcs.controllers.ScriptController; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.items.ItemScripted; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.event.ItemEvent; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.item.ScriptCustomItem; +import noppes.npcs.scripted.wrapper.NpcAPI; + import java.util.HashMap; public class ScriptItemEventHandler { diff --git a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java index d2a49cb65..0257001a4 100644 --- a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java @@ -30,8 +30,8 @@ import noppes.npcs.constants.EnumQuestType; import noppes.npcs.controllers.*; import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.entity.EntityNPCInterface; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptPlayer; +import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptPlayerEventHandler { public ScriptPlayerEventHandler() { diff --git a/src/main/java/noppes/npcs/client/PacketHandlerClient.java b/src/main/java/noppes/npcs/client/PacketHandlerClient.java index 9743a1e12..d3cfca705 100644 --- a/src/main/java/noppes/npcs/client/PacketHandlerClient.java +++ b/src/main/java/noppes/npcs/client/PacketHandlerClient.java @@ -43,8 +43,6 @@ import noppes.npcs.entity.EntityNPCInterface; import cpw.mods.fml.common.ObfuscationReflectionHelper; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent; -import noppes.npcs.scripted.NpcAPI; -import noppes.npcs.scripted.item.ScriptItemStack; public class PacketHandlerClient extends PacketHandlerServer{ diff --git a/src/main/java/noppes/npcs/controllers/CustomGuiController.java b/src/main/java/noppes/npcs/controllers/CustomGuiController.java index 1849561e0..53d36a672 100644 --- a/src/main/java/noppes/npcs/controllers/CustomGuiController.java +++ b/src/main/java/noppes/npcs/controllers/CustomGuiController.java @@ -10,13 +10,12 @@ import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumScriptType; import noppes.npcs.containers.ContainerCustomGui; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.event.CustomGuiEvent; import noppes.npcs.scripted.gui.ScriptGui; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.overlay.ScriptOverlay; -import noppes.npcs.scripted.wrapper.WrapperNpcAPI; +import noppes.npcs.scripted.wrapper.NpcAPI; import java.io.IOException; @@ -78,7 +77,7 @@ public class CustomGuiController { getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_BUTTON, event); } - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onSlotChange(CustomGuiEvent.SlotEvent event) { @@ -87,7 +86,7 @@ public class CustomGuiController { getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_SLOT, event); } - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onCustomGuiUnfocused(CustomGuiEvent.UnfocusedEvent event) { @@ -96,7 +95,7 @@ public class CustomGuiController { getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_TEXTFIELD, event); } - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onScrollClick(CustomGuiEvent.ScrollEvent event) { @@ -105,7 +104,7 @@ public class CustomGuiController { getOpenGui(player).getScriptHandler().callScript(EnumScriptType.CUSTOM_GUI_SCROLL, event); } - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static void onClose(CustomGuiEvent.CloseEvent event) { @@ -113,7 +112,7 @@ public class CustomGuiController { ScriptController.Instance.playerScripts.callScript(EnumScriptType.CUSTOM_GUI_CLOSED, event); } - WrapperNpcAPI.EVENT_BUS.post(event); + NpcAPI.EVENT_BUS.post(event); } public static ScriptGui getOpenGui(EntityPlayer player) { diff --git a/src/main/java/noppes/npcs/controllers/Quest.java b/src/main/java/noppes/npcs/controllers/Quest.java index 739b32010..cdc92a150 100644 --- a/src/main/java/noppes/npcs/controllers/Quest.java +++ b/src/main/java/noppes/npcs/controllers/Quest.java @@ -17,13 +17,13 @@ import noppes.npcs.quests.QuestItem; import noppes.npcs.quests.QuestKill; import noppes.npcs.quests.QuestLocation; import noppes.npcs.scripted.CustomNPCsException; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.handler.data.IQuest; import noppes.npcs.scripted.interfaces.handler.data.IQuestCategory; import noppes.npcs.scripted.interfaces.handler.data.IQuestInterface; import noppes.npcs.scripted.interfaces.handler.data.IQuestObjective; import noppes.npcs.scripted.interfaces.IContainer; import noppes.npcs.scripted.interfaces.entity.IPlayer; +import noppes.npcs.scripted.wrapper.NpcAPI; public class Quest implements ICompatibilty, IQuest { public int version = VersionCompatibility.ModRev; diff --git a/src/main/java/noppes/npcs/controllers/ScriptContainer.java b/src/main/java/noppes/npcs/controllers/ScriptContainer.java index 3697a54d9..1cc4d8a9f 100644 --- a/src/main/java/noppes/npcs/controllers/ScriptContainer.java +++ b/src/main/java/noppes/npcs/controllers/ScriptContainer.java @@ -18,10 +18,8 @@ import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.CustomNpcs; import noppes.npcs.NBTTags; -import noppes.npcs.NoppesUtilServer; import noppes.npcs.constants.EnumScriptType; -import noppes.npcs.scripted.NpcAPI; -import scala.Char; +import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptContainer { private static final String lock = "lock"; diff --git a/src/main/java/noppes/npcs/controllers/data/ForgeDataScript.java b/src/main/java/noppes/npcs/controllers/data/ForgeDataScript.java index 74d1e43ee..f4e548b1b 100644 --- a/src/main/java/noppes/npcs/controllers/data/ForgeDataScript.java +++ b/src/main/java/noppes/npcs/controllers/data/ForgeDataScript.java @@ -21,9 +21,6 @@ import noppes.npcs.NBTTags; import noppes.npcs.constants.EnumScriptType; import noppes.npcs.controllers.IScriptHandler; import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.wrapper.WrapperNpcAPI; - -import javax.script.ScriptEngine; public class ForgeDataScript implements IScriptHandler { private List scripts = new ArrayList(); diff --git a/src/main/java/noppes/npcs/items/ItemScripted.java b/src/main/java/noppes/npcs/items/ItemScripted.java index 7438a5660..4f8991bd2 100644 --- a/src/main/java/noppes/npcs/items/ItemScripted.java +++ b/src/main/java/noppes/npcs/items/ItemScripted.java @@ -19,10 +19,10 @@ import noppes.npcs.CustomNpcs; import noppes.npcs.EventHooks; import noppes.npcs.constants.EnumGuiType; import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.event.ItemEvent; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptCustomItem; +import noppes.npcs.scripted.wrapper.NpcAPI; import org.lwjgl.opengl.GL11; public class ItemScripted extends Item implements ItemRenderInterface { diff --git a/src/main/java/noppes/npcs/scripted/NpcAPI.java b/src/main/java/noppes/npcs/scripted/AbstractNpcAPI.java similarity index 90% rename from src/main/java/noppes/npcs/scripted/NpcAPI.java rename to src/main/java/noppes/npcs/scripted/AbstractNpcAPI.java index 0280d43b2..0a9a2847d 100644 --- a/src/main/java/noppes/npcs/scripted/NpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/AbstractNpcAPI.java @@ -24,10 +24,10 @@ import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.item.IItemStack; -public abstract class NpcAPI { - private static NpcAPI instance = null; +public abstract class AbstractNpcAPI { + private static AbstractNpcAPI instance = null; - public NpcAPI() { + public AbstractNpcAPI() { } public abstract ICustomNpc createNPC(World var1); @@ -64,15 +64,15 @@ public abstract class NpcAPI { return Loader.isModLoaded("customnpcs"); } - public static NpcAPI Instance() { + public static AbstractNpcAPI Instance() { if (instance != null) { return instance; } else if (!IsAvailable()) { return null; } else { try { - Class c = Class.forName("noppes.npcs.scripted.wrapper.WrapperNpcAPI"); - instance = (NpcAPI) c.getMethod("Instance").invoke((Object) null); + Class c = Class.forName("noppes.npcs.scripted.wrapper.NpcAPI"); + instance = (AbstractNpcAPI) c.getMethod("Instance").invoke((Object) null); } catch (Exception var1) { var1.printStackTrace(); } diff --git a/src/main/java/noppes/npcs/scripted/ScriptBlock.java b/src/main/java/noppes/npcs/scripted/ScriptBlock.java index d7ab06245..1426c638e 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptBlock.java +++ b/src/main/java/noppes/npcs/scripted/ScriptBlock.java @@ -15,6 +15,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import noppes.npcs.scripted.interfaces.*; +import noppes.npcs.scripted.wrapper.NpcAPI; import noppes.npcs.util.LRUHashMap; public class ScriptBlock implements IBlock { diff --git a/src/main/java/noppes/npcs/scripted/ScriptContainer.java b/src/main/java/noppes/npcs/scripted/ScriptContainer.java index a607d1431..ab4625e12 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptContainer.java +++ b/src/main/java/noppes/npcs/scripted/ScriptContainer.java @@ -16,6 +16,7 @@ import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.interfaces.IContainer; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptItemStack; +import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptContainer implements IContainer { private IInventory inventory; diff --git a/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java b/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java index 5eb9e3966..a4ddb2408 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java +++ b/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java @@ -1,12 +1,12 @@ package noppes.npcs.scripted; -import jdk.nashorn.internal.ir.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; import noppes.npcs.scripted.interfaces.INbt; import noppes.npcs.scripted.interfaces.ITileEntity; +import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptTileEntity implements ITileEntity { protected T tileEntity; diff --git a/src/main/java/noppes/npcs/scripted/ScriptWorld.java b/src/main/java/noppes/npcs/scripted/ScriptWorld.java index 61af7f4d7..f71528d65 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptWorld.java +++ b/src/main/java/noppes/npcs/scripted/ScriptWorld.java @@ -31,7 +31,7 @@ import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.IWorld; import noppes.npcs.scripted.item.ScriptItemStack; -import noppes.npcs.scripted.wrapper.WrapperNpcAPI; +import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptWorld implements IWorld { private static Map tempData = new HashMap(); @@ -325,7 +325,7 @@ public class ScriptWorld implements IWorld { * @return Returns the item */ public IItemStack createItem(String id, int damage, int size){ - return WrapperNpcAPI.Instance().createItem(id,damage,size); + return NpcAPI.Instance().createItem(id,damage,size); } /** diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java index 5752053c6..f07bd9efe 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java @@ -6,7 +6,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.interfaces.item.IItemStack; -import noppes.npcs.scripted.item.ScriptItemStack; +import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptDBCPlayer extends ScriptPlayer{ public T player; @@ -432,10 +432,10 @@ public class ScriptDBCPlayer extends ScriptPlayer{ this.player.writeToNBT(compound); NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag",10); - ScriptItemStack[] itemList = new ScriptItemStack[list.tagCount()]; + IItemStack[] itemList = new IItemStack[list.tagCount()]; for (int i = 0; i < list.tagCount(); i++) { ItemStack itemStack = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i)); - itemList[i] = new ScriptItemStack(itemStack); + itemList[i] = NpcAPI.Instance().getIItemStack(itemStack); } return itemList; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index 461825c64..a143acf7e 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -29,6 +29,7 @@ import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.INbt; import noppes.npcs.scripted.interfaces.IPos; import noppes.npcs.scripted.item.ScriptItemStack; +import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptEntity implements IEntity { protected T entity; @@ -740,6 +741,6 @@ public class ScriptEntity implements IEntity { } public ScriptWorld getWorld() { - return (ScriptWorld)NpcAPI.Instance().getIWorld((WorldServer) entity.worldObj); + return (ScriptWorld) NpcAPI.Instance().getIWorld((WorldServer) entity.worldObj); } } \ No newline at end of file diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java index 8f41c8971..5b8ea05c0 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java @@ -11,8 +11,8 @@ import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.constants.EntityType; import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; +import noppes.npcs.scripted.wrapper.NpcAPI; import noppes.npcs.scripted.wrapper.ScriptDamageSource; -import noppes.npcs.scripted.wrapper.WrapperNpcAPI; public class ScriptLivingBase extends ScriptEntity implements IEntityLivingBase { protected T entity; @@ -174,7 +174,7 @@ public class ScriptLivingBase extends ScriptEntity extends ScriptEntity extends ScriptLiving imp * @return The item held in the right hand */ public IItemStack getRightItem(){ - return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.getWeapon()); + return NpcAPI.Instance().getIItemStack(npc.inventory.getWeapon()); } /** @@ -380,7 +380,7 @@ public class ScriptNpc extends ScriptLiving imp * @return The item held in the left hand */ public IItemStack getLefttItem(){ - return WrapperNpcAPI.Instance().getIItemStack(npc.getOffHand()); + return NpcAPI.Instance().getIItemStack(npc.getOffHand()); } /** @@ -398,7 +398,7 @@ public class ScriptNpc extends ScriptLiving imp * @return Returns the projectile the npc uses */ public IItemStack getProjectileItem(){ - return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.getProjectile()); + return NpcAPI.Instance().getIItemStack(npc.inventory.getProjectile()); } /** @@ -483,7 +483,7 @@ public class ScriptNpc extends ScriptLiving imp */ @Override public IItemStack getArmor(int slot){ - return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.armor.get(slot)); + return NpcAPI.Instance().getIItemStack(npc.inventory.armor.get(slot)); } /** @@ -506,7 +506,7 @@ public class ScriptNpc extends ScriptLiving imp * @return */ public IItemStack getLootItem(int slot) { - return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.getStackInSlot(slot+7)); + return NpcAPI.Instance().getIItemStack(npc.inventory.getStackInSlot(slot+7)); } /** diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index 9ceb1083b..8d3ed0a61 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -28,7 +28,7 @@ import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay; import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.overlay.ScriptOverlay; -import noppes.npcs.scripted.wrapper.WrapperNpcAPI; +import noppes.npcs.scripted.wrapper.NpcAPI; import noppes.npcs.util.ValueUtil; import java.util.ArrayList; @@ -247,7 +247,7 @@ public class ScriptPlayer extends ScriptLivingBase for(int i = 0; i < player.inventory.mainInventory.length; i++){ ItemStack item = player.inventory.mainInventory[i]; if(item != null) - items[i] = WrapperNpcAPI.Instance().getIItemStack(item); + items[i] = NpcAPI.Instance().getIItemStack(item); } return items; } diff --git a/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java b/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java index d7f46473f..537a889c1 100644 --- a/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java @@ -6,10 +6,10 @@ package noppes.npcs.scripted.event; import cpw.mods.fml.common.eventhandler.Event; -import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.AbstractNpcAPI; public class CustomNPCsEvent extends Event{ - public final NpcAPI API = NpcAPI.Instance(); + public final AbstractNpcAPI API = AbstractNpcAPI.Instance(); public CustomNPCsEvent() { } diff --git a/src/main/java/noppes/npcs/scripted/event/ItemEvent.java b/src/main/java/noppes/npcs/scripted/event/ItemEvent.java index 679db5203..15cafafee 100644 --- a/src/main/java/noppes/npcs/scripted/event/ItemEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/ItemEvent.java @@ -1,19 +1,19 @@ package noppes.npcs.scripted.event; import cpw.mods.fml.common.eventhandler.Cancelable; -import noppes.npcs.scripted.interfaces.item.ICustomItem; +import noppes.npcs.scripted.interfaces.item.IItemCustom; import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.entity.IPlayer; public class ItemEvent extends CustomNPCsEvent { - public ICustomItem item; + public IItemCustom item; - public ItemEvent(ICustomItem item) { + public ItemEvent(IItemCustom item) { this.item = item; } public static class InitEvent extends ItemEvent { - public InitEvent(ICustomItem item) { + public InitEvent(IItemCustom item) { super(item); } } @@ -21,7 +21,7 @@ public class ItemEvent extends CustomNPCsEvent { public static class UpdateEvent extends ItemEvent { public IEntity entity; - public UpdateEvent(ICustomItem item, IEntity entity) { + public UpdateEvent(IItemCustom item, IEntity entity) { super(item); this.entity = entity; } @@ -32,7 +32,7 @@ public class ItemEvent extends CustomNPCsEvent { public IEntity entity; public IPlayer player; - public TossedEvent(ICustomItem item, IPlayer player, IEntity entity) { + public TossedEvent(IItemCustom item, IPlayer player, IEntity entity) { super(item); this.entity = entity; this.player = player; @@ -42,7 +42,7 @@ public class ItemEvent extends CustomNPCsEvent { public static class PickedUpEvent extends ItemEvent { public IPlayer player; - public PickedUpEvent(ICustomItem item, IPlayer player) { + public PickedUpEvent(IItemCustom item, IPlayer player) { super(item); this.player = player; } @@ -51,7 +51,7 @@ public class ItemEvent extends CustomNPCsEvent { @Cancelable public static class SpawnEvent extends ItemEvent { public IEntity entity; - public SpawnEvent(ICustomItem item, IEntity entity){ + public SpawnEvent(IItemCustom item, IEntity entity){ super(item); this.entity = entity; } @@ -63,7 +63,7 @@ public class ItemEvent extends CustomNPCsEvent { public final Object target; public IPlayer player; - public InteractEvent(ICustomItem item, IPlayer player, int type, Object target) { + public InteractEvent(IItemCustom item, IPlayer player, int type, Object target) { super(item); this.type = type; this.target = target; @@ -77,7 +77,7 @@ public class ItemEvent extends CustomNPCsEvent { public final Object target; public IEntity swingingEntity; - public AttackEvent(ICustomItem item, IEntity swingingEntity, int type, Object target) { + public AttackEvent(IItemCustom item, IEntity swingingEntity, int type, Object target) { super(item); this.type = type; this.target = target; @@ -89,7 +89,7 @@ public class ItemEvent extends CustomNPCsEvent { public final IPlayer player; public final int duration; - public StartUsingItem(ICustomItem item, IPlayer player, int duration){ + public StartUsingItem(IItemCustom item, IPlayer player, int duration){ super(item); this.player = player; this.duration = duration; @@ -99,7 +99,7 @@ public class ItemEvent extends CustomNPCsEvent { public final IPlayer player; public final int duration; - public UsingItem(ICustomItem item, IPlayer player, int duration){ + public UsingItem(IItemCustom item, IPlayer player, int duration){ super(item); this.player = player; this.duration = duration; @@ -109,7 +109,7 @@ public class ItemEvent extends CustomNPCsEvent { public final IPlayer player; public final int duration; - public StopUsingItem(ICustomItem item, IPlayer player, int duration){ + public StopUsingItem(IItemCustom item, IPlayer player, int duration){ super(item); this.player = player; this.duration = duration; @@ -119,7 +119,7 @@ public class ItemEvent extends CustomNPCsEvent { public final IPlayer player; public final int duration; - public FinishUsingItem(ICustomItem item, IPlayer player, int duration){ + public FinishUsingItem(IItemCustom item, IPlayer player, int duration){ super(item); this.player = player; this.duration = duration; diff --git a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java index e0ffe6a8c..03de543d6 100644 --- a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java @@ -12,13 +12,13 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.DamageSource; import noppes.npcs.controllers.Dialog; import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.*; import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.item.IItemStack; +import noppes.npcs.scripted.wrapper.NpcAPI; public class NpcEvent extends CustomNPCsEvent { public final ICustomNpc npc; diff --git a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java index f702353a2..390f8279a 100644 --- a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java @@ -13,7 +13,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.*; import noppes.npcs.scripted.entity.ScriptLivingBase; import noppes.npcs.scripted.interfaces.*; import noppes.npcs.scripted.interfaces.entity.IEntity; @@ -21,6 +20,7 @@ import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptItemStack; +import noppes.npcs.scripted.wrapper.NpcAPI; public class PlayerEvent extends CustomNPCsEvent { public final IPlayer player; diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiItemSlot.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiItemSlot.java index 9bd829d73..2697c47da 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiItemSlot.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiItemSlot.java @@ -3,9 +3,9 @@ package noppes.npcs.scripted.gui; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.gui.IItemSlot; import noppes.npcs.scripted.interfaces.item.IItemStack; +import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptGuiItemSlot extends ScriptGuiComponent implements IItemSlot { IItemStack stack; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java b/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java index 5080ad2ae..561ddca1c 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java @@ -6,9 +6,7 @@ package noppes.npcs.scripted.interfaces; import net.minecraft.block.Block; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.ScriptTileEntity; public interface IBlock { diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ITileEntity.java b/src/main/java/noppes/npcs/scripted/interfaces/ITileEntity.java index ca2dd8e9e..e46dc7978 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ITileEntity.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ITileEntity.java @@ -1,10 +1,6 @@ package noppes.npcs.scripted.interfaces; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.WorldServer; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.ScriptBlock; import noppes.npcs.scripted.ScriptWorld; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java index 69f2bbbe3..2b9e6d624 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java @@ -6,10 +6,6 @@ package noppes.npcs.scripted.interfaces.entity; import net.minecraft.entity.Entity; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.BlockPos; -import noppes.npcs.scripted.NpcAPI; -import noppes.npcs.scripted.ScriptBlockPos; import noppes.npcs.scripted.ScriptParticle; import noppes.npcs.scripted.ScriptWorld; import noppes.npcs.scripted.entity.ScriptEntity; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/item/IItemArmor.java b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemArmor.java new file mode 100644 index 000000000..1b4a9c3e6 --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemArmor.java @@ -0,0 +1,7 @@ +package noppes.npcs.scripted.interfaces.item; + +public interface IItemArmor { + int getArmorSlot(); + + String getArmorMaterial(); +} diff --git a/src/main/java/noppes/npcs/scripted/interfaces/item/IItemBlock.java b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemBlock.java new file mode 100644 index 000000000..6776a81ec --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemBlock.java @@ -0,0 +1,5 @@ +package noppes.npcs.scripted.interfaces.item; + +public interface IItemBlock { + String getBlockName(); +} diff --git a/src/main/java/noppes/npcs/scripted/interfaces/item/IItemBook.java b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemBook.java new file mode 100644 index 000000000..87d72e3fa --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemBook.java @@ -0,0 +1,15 @@ +package noppes.npcs.scripted.interfaces.item; + +public interface IItemBook { + String[] getText(); + + void setText(String[] var1); + + String getAuthor(); + + void setAuthor(String var1); + + String getTitle(); + + void setTitle(String var1); +} diff --git a/src/main/java/noppes/npcs/scripted/interfaces/item/ICustomItem.java b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemCustom.java similarity index 97% rename from src/main/java/noppes/npcs/scripted/interfaces/item/ICustomItem.java rename to src/main/java/noppes/npcs/scripted/interfaces/item/IItemCustom.java index 9ee43e389..e36e84907 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/item/ICustomItem.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemCustom.java @@ -1,6 +1,6 @@ package noppes.npcs.scripted.interfaces.item; -public interface ICustomItem extends IItemStack { +public interface IItemCustom extends IItemStack { String getTexture(); void setTexture(String var2); diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java index 721e3b694..f0a683a22 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java @@ -10,11 +10,11 @@ import noppes.npcs.controllers.IScriptHandler; import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.controllers.ScriptController; import noppes.npcs.scripted.CustomNPCsException; -import noppes.npcs.scripted.interfaces.item.ICustomItem; +import noppes.npcs.scripted.interfaces.item.IItemCustom; import java.util.*; -public class ScriptCustomItem extends ScriptItemStack implements ICustomItem, IScriptHandler { +public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IScriptHandler { public List scripts = new ArrayList(); public String scriptLanguage = "ECMAScript"; public boolean enabled = false; diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptItemArmor.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemArmor.java new file mode 100644 index 000000000..473db92bf --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemArmor.java @@ -0,0 +1,19 @@ +package noppes.npcs.scripted.item; + +import net.minecraft.item.ItemStack; +import noppes.npcs.scripted.interfaces.item.IItemArmor; + +public class ScriptItemArmor extends ScriptItemStack implements IItemArmor { + + public ScriptItemArmor(ItemStack item) { + super(item); + } + + public int getArmorSlot() { + return 0; + } + + public String getArmorMaterial() { + return null; + } +} diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptItemBlock.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemBlock.java new file mode 100644 index 000000000..fee327802 --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemBlock.java @@ -0,0 +1,15 @@ +package noppes.npcs.scripted.item; + +import net.minecraft.item.ItemStack; +import noppes.npcs.scripted.interfaces.item.IItemBlock; + +public class ScriptItemBlock extends ScriptItemStack implements IItemBlock { + + public ScriptItemBlock(ItemStack item) { + super(item); + } + + public String getBlockName() { + return null; + } +} diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java new file mode 100644 index 000000000..7c59158ad --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java @@ -0,0 +1,35 @@ +package noppes.npcs.scripted.item; + +import net.minecraft.item.ItemStack; +import noppes.npcs.scripted.interfaces.item.IItemBook; + +public class ScriptItemBook extends ScriptItemStack implements IItemBook { + + public ScriptItemBook(ItemStack item) { + super(item); + } + + public String[] getText() { + return new String[0]; + } + + public void setText(String[] var1) { + + } + + public String getAuthor() { + return null; + } + + public void setAuthor(String var1) { + + } + + public String getTitle() { + return null; + } + + public void setTitle(String var1) { + + } +} diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java index 09909fbfa..ea5ddad32 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java @@ -19,10 +19,10 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; import noppes.npcs.scripted.CustomNPCsException; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.ScriptNbt; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.INbt; +import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptItemStack implements IItemStack { public ItemStack item; diff --git a/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java b/src/main/java/noppes/npcs/scripted/wrapper/NpcAPI.java similarity index 97% rename from src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java rename to src/main/java/noppes/npcs/scripted/wrapper/NpcAPI.java index a83d1f353..bebe92068 100644 --- a/src/main/java/noppes/npcs/scripted/wrapper/WrapperNpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/wrapper/NpcAPI.java @@ -45,7 +45,7 @@ import noppes.npcs.scripted.interfaces.*; import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.gui.ICustomGui; -import noppes.npcs.scripted.interfaces.item.ICustomItem; +import noppes.npcs.scripted.interfaces.item.IItemCustom; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay; import noppes.npcs.scripted.item.ScriptCustomItem; @@ -55,12 +55,12 @@ import noppes.npcs.util.JsonException; import noppes.npcs.util.LRUHashMap; import noppes.npcs.util.NBTJsonUtil; -public class WrapperNpcAPI extends NpcAPI { +public class NpcAPI extends AbstractNpcAPI { private static final Map worldCache = new LRUHashMap(10); public static final EventBus EVENT_BUS = new EventBus(); - private static NpcAPI instance = null; + private static AbstractNpcAPI instance = null; - public WrapperNpcAPI() { + public NpcAPI() { } public static void clearCache() { @@ -163,9 +163,9 @@ public class WrapperNpcAPI extends NpcAPI { } } - public static NpcAPI Instance() { + public static AbstractNpcAPI Instance() { if (instance == null) { - instance = new WrapperNpcAPI(); + instance = new NpcAPI(); } return instance; @@ -177,12 +177,22 @@ public class WrapperNpcAPI extends NpcAPI { public IItemStack getIItemStack(ItemStack itemstack) { if(itemstack.getItem() instanceof ItemScripted){ - return (ICustomItem) (itemstack.stackSize > 0 ? new ScriptCustomItem(itemstack) : new ScriptCustomItem(new ItemStack(Item.getItemById(0)))); + return (IItemCustom) (itemstack.stackSize > 0 ? new ScriptCustomItem(itemstack) : new ScriptCustomItem(new ItemStack(Item.getItemById(0)))); } else { return (IItemStack) (itemstack.stackSize > 0 ? new ScriptItemStack(itemstack) : new ScriptItemStack(new ItemStack(Item.getItemById(0)))); } } + public IItemStack createItem(String id, int damage, int size){ + Item item = (Item)Item.itemRegistry.getObject(id); + if(item == null) + return null; + if(item instanceof ItemScripted) + return new ScriptCustomItem(new ItemStack(item, size, damage)); + else + return new ScriptItemStack(new ItemStack(item, size, damage)); + } + public IWorld getIWorld(WorldServer world) { ScriptWorld w = (ScriptWorld)worldCache.get(world.provider.dimensionId); if (w != null) { @@ -270,16 +280,6 @@ public class WrapperNpcAPI extends NpcAPI { return arr; } - public IItemStack createItem(String id, int damage, int size){ - Item item = (Item)Item.itemRegistry.getObject(id); - if(item == null) - return null; - if(item instanceof ItemScripted) - return new ScriptCustomItem(new ItemStack(item, size, damage)); - else - return new ScriptItemStack(new ItemStack(item, size, damage)); - } - public void playSoundAtEntity(ScriptEntity entity, String sound, float volume, float pitch){ entity.getWorld().getMCWorld().playSoundAtEntity(entity.getMCEntity(), sound, volume, pitch); } From cf33b90b267cc9f660407b49e8f89f0c055547bd Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 11 May 2022 22:08:31 -0500 Subject: [PATCH 32/75] Used interfaces in implementations instead of the real classes for most scripted classes. --- src/main/java/foxz/command/CmdFaction.java | 5 - src/main/java/noppes/npcs/CustomNpcs.java | 2 +- src/main/java/noppes/npcs/DataScript.java | 7 +- src/main/java/noppes/npcs/EventHooks.java | 115 +++++++++--------- .../java/noppes/npcs/NoppesUtilPlayer.java | 12 +- .../java/noppes/npcs/NoppesUtilServer.java | 6 +- .../java/noppes/npcs/PacketHandlerServer.java | 13 +- .../noppes/npcs/ScriptItemEventHandler.java | 42 +++---- .../noppes/npcs/ScriptPlayerEventHandler.java | 72 +++++------ .../client/renderer/CustomItemRenderer.java | 3 +- .../npcs/controllers/CustomGuiController.java | 12 +- .../npcs/controllers/FactionOptions.java | 4 - .../npcs/controllers/PlayerFactionData.java | 5 +- .../java/noppes/npcs/controllers/Quest.java | 2 +- .../npcs/controllers/ScriptContainer.java | 2 +- .../npcs/controllers/ScriptController.java | 30 +---- .../npcs/controllers/ScriptEntityData.java | 8 +- .../controllers/ServerCloneController.java | 5 +- .../npcs/controllers/data/NPCDataScript.java | 3 +- .../controllers/data/PlayerDataScript.java | 6 +- .../npcs/entity/EntityNPCInterface.java | 3 +- .../java/noppes/npcs/items/ItemScripted.java | 12 +- .../npcs/scripted/{wrapper => }/NpcAPI.java | 20 +-- .../noppes/npcs/scripted/ScriptBlock.java | 1 - .../noppes/npcs/scripted/ScriptContainer.java | 8 +- .../{wrapper => }/ScriptDamageSource.java | 6 +- .../noppes/npcs/scripted/ScriptFaction.java | 22 ++-- .../noppes/npcs/scripted/ScriptParticle.java | 7 +- .../npcs/scripted/ScriptTileEntity.java | 1 - .../noppes/npcs/scripted/ScriptWorld.java | 61 +++++----- .../npcs/scripted/entity/ScriptDBCPlayer.java | 2 +- .../npcs/scripted/entity/ScriptEntity.java | 41 +++---- .../npcs/scripted/entity/ScriptLiving.java | 16 +-- .../scripted/entity/ScriptLivingBase.java | 31 +++-- .../npcs/scripted/entity/ScriptNpc.java | 46 +++---- .../npcs/scripted/entity/ScriptPlayer.java | 26 ++-- .../npcs/scripted/event/CustomNPCsEvent.java | 2 +- .../noppes/npcs/scripted/event/NpcEvent.java | 24 ++-- .../npcs/scripted/event/PlayerEvent.java | 19 ++- .../scripted/event/ScriptEventAttack.java | 10 +- .../scripted/event/ScriptEventDamaged.java | 10 +- .../scripted/event/ScriptEventDialog.java | 3 +- .../scripted/event/ScriptEventKilled.java | 14 ++- .../scripted/event/ScriptEventTarget.java | 13 +- .../noppes/npcs/scripted/gui/ScriptGui.java | 3 +- .../npcs/scripted/gui/ScriptGuiItemSlot.java | 2 +- .../{ => interfaces}/AbstractNpcAPI.java | 13 +- .../npcs/scripted/interfaces/IContainer.java | 7 +- .../npcs/scripted/interfaces/IParticle.java | 4 +- .../npcs/scripted/interfaces/IWorld.java | 36 +++--- .../interfaces/entity/ICustomNpc.java | 23 ++-- .../scripted/interfaces/entity/IEntity.java | 17 ++- .../interfaces/entity/IEntityLivingBase.java | 17 ++- .../scripted/interfaces/entity/IPlayer.java | 14 +-- .../scripted/interfaces/item/IItemCustom.java | 30 +++++ .../npcs/scripted/item/ScriptItemStack.java | 3 +- .../npcs/scripted/overlay/ScriptOverlay.java | 3 +- .../scripted/roles/ScriptJobFollower.java | 6 +- .../npcs/scripted/roles/ScriptJobHealer.java | 4 +- .../npcs/scripted/roles/ScriptJobSpawner.java | 8 +- .../scripted/roles/ScriptRoleFollower.java | 10 +- .../npcs/scripted/roles/ScriptRoleTrader.java | 6 +- .../scripted/wrapper/WrapperEntityData.java | 59 --------- 63 files changed, 466 insertions(+), 551 deletions(-) rename src/main/java/noppes/npcs/scripted/{wrapper => }/NpcAPI.java (94%) rename src/main/java/noppes/npcs/scripted/{wrapper => }/ScriptDamageSource.java (80%) rename src/main/java/noppes/npcs/scripted/{ => interfaces}/AbstractNpcAPI.java (86%) delete mode 100644 src/main/java/noppes/npcs/scripted/wrapper/WrapperEntityData.java diff --git a/src/main/java/foxz/command/CmdFaction.java b/src/main/java/foxz/command/CmdFaction.java index fbad7b91f..fdfab8784 100644 --- a/src/main/java/foxz/command/CmdFaction.java +++ b/src/main/java/foxz/command/CmdFaction.java @@ -2,10 +2,7 @@ package foxz.command; import java.util.List; -import net.minecraft.entity.player.EntityPlayerMP; -import noppes.npcs.EventHooks; import noppes.npcs.controllers.Faction; -import noppes.npcs.controllers.FactionController; import noppes.npcs.controllers.PlayerData; import noppes.npcs.controllers.PlayerFactionData; import foxz.commandhelper.ChMcLogger; @@ -13,8 +10,6 @@ import foxz.commandhelper.annotations.Command; import foxz.commandhelper.annotations.SubCommand; import foxz.commandhelper.permissions.OpOnly; import foxz.commandhelper.permissions.ParamCheck; -import noppes.npcs.scripted.entity.ScriptPlayer; -import noppes.npcs.scripted.event.FactionEvent; @Command( name = "faction", diff --git a/src/main/java/noppes/npcs/CustomNpcs.java b/src/main/java/noppes/npcs/CustomNpcs.java index 9b13a1ff2..e7350179a 100644 --- a/src/main/java/noppes/npcs/CustomNpcs.java +++ b/src/main/java/noppes/npcs/CustomNpcs.java @@ -26,7 +26,7 @@ import noppes.npcs.controllers.*; import noppes.npcs.enchants.EnchantInterface; import noppes.npcs.entity.*; import noppes.npcs.entity.old.*; -import noppes.npcs.scripted.wrapper.NpcAPI; +import noppes.npcs.scripted.NpcAPI; import java.io.File; import java.util.Set; diff --git a/src/main/java/noppes/npcs/DataScript.java b/src/main/java/noppes/npcs/DataScript.java index eb85f950b..bd790f8c2 100644 --- a/src/main/java/noppes/npcs/DataScript.java +++ b/src/main/java/noppes/npcs/DataScript.java @@ -16,14 +16,13 @@ import noppes.npcs.controllers.IScriptHandler; import noppes.npcs.controllers.ScriptController; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.event.ScriptEvent; -import noppes.npcs.scripted.entity.ScriptNpc; import noppes.npcs.scripted.ScriptWorld; import noppes.npcs.scripted.constants.EntityType; import noppes.npcs.scripted.constants.JobType; import noppes.npcs.scripted.constants.RoleType; import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import noppes.npcs.scripted.interfaces.IWorld; -import noppes.npcs.scripted.wrapper.NpcAPI; +import noppes.npcs.scripted.NpcAPI; public class DataScript implements IScriptHandler { public List scripts = new ArrayList(); @@ -47,7 +46,7 @@ public class DataScript implements IScriptHandler { } this.npc = npc; - dummyNpc = new ScriptNpc<>(npc); + dummyNpc = (ICustomNpc) NpcAPI.Instance().getIEntity(npc); if(npc.worldObj instanceof WorldServer) dummyWorld = NpcAPI.Instance().getIWorld((WorldServer) npc.worldObj);//new ScriptWorld((WorldServer) npc.worldObj); @@ -119,7 +118,7 @@ public class DataScript implements IScriptHandler { for(int i = 0; i + 1 < obs.length; i += 2){ Object ob = obs[i + 1]; if(ob instanceof Entity) - ob = ScriptController.Instance.getScriptForEntity((Entity)ob); + ob = NpcAPI.Instance().getIEntity((Entity)ob); script.engine.put(obs[i].toString(), ob); } diff --git a/src/main/java/noppes/npcs/EventHooks.java b/src/main/java/noppes/npcs/EventHooks.java index 4bb574437..6e8d8ea7d 100644 --- a/src/main/java/noppes/npcs/EventHooks.java +++ b/src/main/java/noppes/npcs/EventHooks.java @@ -23,8 +23,6 @@ import noppes.npcs.controllers.*; import noppes.npcs.controllers.data.ForgeDataScript; import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.entity.EntityNPCInterface; -import noppes.npcs.scripted.*; -import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.event.*; import noppes.npcs.scripted.event.PlayerEvent.ChatEvent; import noppes.npcs.scripted.event.PlayerEvent.ContainerOpen; @@ -38,10 +36,9 @@ import noppes.npcs.scripted.interfaces.*; import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.gui.ICustomGui; +import noppes.npcs.scripted.interfaces.item.IItemCustom; import noppes.npcs.scripted.interfaces.item.IItemStack; -import noppes.npcs.scripted.item.ScriptCustomItem; -import noppes.npcs.scripted.item.ScriptItemStack; -import noppes.npcs.scripted.wrapper.NpcAPI; +import noppes.npcs.scripted.NpcAPI; import noppes.npcs.constants.EnumScriptType; import org.apache.commons.lang3.StringUtils; @@ -51,7 +48,7 @@ public class EventHooks { public EventHooks() { } - public static void onScriptItemInit(ScriptCustomItem handler) { + public static void onScriptItemInit(IItemCustom handler) { if (!handler.isClient()) { ItemEvent.InitEvent event = new ItemEvent.InitEvent(handler); handler.callScript(EnumScriptType.INIT, event); @@ -59,61 +56,61 @@ public class EventHooks { } } - public static void onScriptItemUpdate(ScriptCustomItem handler, EntityLivingBase player) { + public static void onScriptItemUpdate(IItemCustom handler, EntityLivingBase player) { if (!handler.isClient()) { - ItemEvent.UpdateEvent event = new ItemEvent.UpdateEvent(handler, ScriptController.Instance.getScriptForEntity(player)); + ItemEvent.UpdateEvent event = new ItemEvent.UpdateEvent(handler, NpcAPI.Instance().getIEntity(player)); handler.callScript(EnumScriptType.TICK, event); NpcAPI.EVENT_BUS.post(event); } } - public static boolean onScriptItemTossed(ScriptCustomItem handler, EntityPlayer player, EntityItem entity) { - ItemEvent.TossedEvent event = new ItemEvent.TossedEvent(handler, (ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), ScriptController.Instance.getScriptForEntity(entity)); + public static boolean onScriptItemTossed(IItemCustom handler, EntityPlayer player, EntityItem entity) { + ItemEvent.TossedEvent event = new ItemEvent.TossedEvent(handler, (IPlayer)NpcAPI.Instance().getIEntity(player), NpcAPI.Instance().getIEntity(entity)); handler.callScript(EnumScriptType.TOSSED, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onScriptItemPickedUp(ScriptCustomItem handler, EntityPlayer player) { - ItemEvent.PickedUpEvent event = new ItemEvent.PickedUpEvent(handler, (ScriptPlayer)ScriptController.Instance.getScriptForEntity(player)); + public static boolean onScriptItemPickedUp(IItemCustom handler, EntityPlayer player) { + ItemEvent.PickedUpEvent event = new ItemEvent.PickedUpEvent(handler, (IPlayer)NpcAPI.Instance().getIEntity(player)); handler.callScript(EnumScriptType.PICKEDUP, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onScriptItemSpawn(ScriptCustomItem handler, EntityItem entity) { - ItemEvent.SpawnEvent event = new ItemEvent.SpawnEvent(handler, ScriptController.Instance.getScriptForEntity(entity)); + public static boolean onScriptItemSpawn(IItemCustom handler, EntityItem entity) { + ItemEvent.SpawnEvent event = new ItemEvent.SpawnEvent(handler, NpcAPI.Instance().getIEntity(entity)); handler.callScript(EnumScriptType.SPAWN, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onScriptItemInteract(ScriptCustomItem handler, noppes.npcs.scripted.event.ItemEvent.InteractEvent event) { + public static boolean onScriptItemInteract(IItemCustom handler, noppes.npcs.scripted.event.ItemEvent.InteractEvent event) { handler.callScript(EnumScriptType.INTERACT, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onScriptItemAttack(ScriptCustomItem handler, noppes.npcs.scripted.event.ItemEvent.AttackEvent event) { + public static boolean onScriptItemAttack(IItemCustom handler, noppes.npcs.scripted.event.ItemEvent.AttackEvent event) { handler.callScript(EnumScriptType.ATTACK, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onStartUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) { + public static boolean onStartUsingCustomItem(IItemCustom handler, IPlayer player, int duration) { ItemEvent.StartUsingItem event = new ItemEvent.StartUsingItem(handler, player, duration); handler.callScript(EnumScriptType.START_USING_ITEM, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) { + public static boolean onUsingCustomItem(IItemCustom handler, IPlayer player, int duration) { ItemEvent.UsingItem event = new ItemEvent.UsingItem(handler, player, duration); handler.callScript(EnumScriptType.USING_ITEM, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onStopUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) { + public static boolean onStopUsingCustomItem(IItemCustom handler, IPlayer player, int duration) { ItemEvent.StopUsingItem event = new ItemEvent.StopUsingItem(handler, player, duration); handler.callScript(EnumScriptType.STOP_USING_ITEM, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onFinishUsingCustomItem(ScriptCustomItem handler, IPlayer player, int duration) { + public static boolean onFinishUsingCustomItem(IItemCustom handler, IPlayer player, int duration) { ItemEvent.FinishUsingItem event = new ItemEvent.FinishUsingItem(handler, player, duration); handler.callScript(EnumScriptType.FINISH_USING_ITEM, event); return NpcAPI.EVENT_BUS.post(event); @@ -262,13 +259,13 @@ public class EventHooks { NpcAPI.EVENT_BUS.post(event); } - public static void onPlayerInit(PlayerDataScript handler, ScriptPlayer player) { + public static void onPlayerInit(PlayerDataScript handler, IPlayer player) { noppes.npcs.scripted.event.PlayerEvent.InitEvent event = new noppes.npcs.scripted.event.PlayerEvent.InitEvent(player); handler.callScript(EnumScriptType.INIT, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPlayerTick(PlayerDataScript handler, ScriptPlayer player) { + public static void onPlayerTick(PlayerDataScript handler, IPlayer player) { noppes.npcs.scripted.event.PlayerEvent.UpdateEvent event = new noppes.npcs.scripted.event.PlayerEvent.UpdateEvent(player); handler.callScript(EnumScriptType.TICK, event); NpcAPI.EVENT_BUS.post(event); @@ -279,31 +276,31 @@ public class EventHooks { return NpcAPI.EVENT_BUS.post(event); } - public static boolean onStartUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){ + public static boolean onStartUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){ PlayerEvent.StartUsingItem event = new PlayerEvent.StartUsingItem(player, item, duration); handler.callScript(EnumScriptType.START_USING_ITEM, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){ + public static boolean onUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){ PlayerEvent.UsingItem event = new PlayerEvent.UsingItem(player, item, duration); handler.callScript(EnumScriptType.USING_ITEM, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onStopUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){ + public static boolean onStopUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){ PlayerEvent.StopUsingItem event = new PlayerEvent.StopUsingItem(player, item, duration); handler.callScript(EnumScriptType.STOP_USING_ITEM, event); return NpcAPI.EVENT_BUS.post(event); } - public static void onFinishUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){ + public static void onFinishUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){ PlayerEvent.FinishUsingItem event = new PlayerEvent.FinishUsingItem(player, item, duration); handler.callScript(EnumScriptType.FINISH_USING_ITEM, event); NpcAPI.EVENT_BUS.post(event); } - public static boolean onPlayerDropItems(PlayerDataScript handler, ScriptPlayer player, ArrayList entityItems) { + public static boolean onPlayerDropItems(PlayerDataScript handler, IPlayer player, ArrayList entityItems) { IItemStack[] items = new IItemStack[entityItems.size()]; for(int i = 0; i < entityItems.size(); i++){ items[i] = NpcAPI.Instance().getIItemStack(entityItems.get(i).getEntityItem()); } @@ -312,55 +309,55 @@ public class EventHooks { return NpcAPI.EVENT_BUS.post(event); } - public static void onPlayerPickupXP(PlayerDataScript handler, ScriptPlayer player, EntityXPOrb orb) { + public static void onPlayerPickupXP(PlayerDataScript handler, IPlayer player, EntityXPOrb orb) { PlayerEvent.PickupXPEvent event = new PlayerEvent.PickupXPEvent(player, orb); handler.callScript(EnumScriptType.PICKUP_XP, event); NpcAPI.EVENT_BUS.post(event); } - public static boolean onPlayerToss(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) { + public static boolean onPlayerToss(PlayerDataScript handler, IPlayer player, EntityItem entityItem) { PlayerEvent.TossEvent event = new PlayerEvent.TossEvent(player, NpcAPI.Instance().getIItemStack(entityItem.getEntityItem())); handler.callScript(EnumScriptType.TOSS, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onPlayerPickUp(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) { - PickUpEvent event = new PickUpEvent(player, new ScriptItemStack(entityItem.getEntityItem()));//NpcAPI.Instance().getIItemStack(entityItem.getEntityItem())); + public static boolean onPlayerPickUp(PlayerDataScript handler, IPlayer player, EntityItem entityItem) { + PickUpEvent event = new PickUpEvent(player, NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));//NpcAPI.Instance().getIItemStack(entityItem.getEntityItem())); handler.callScript(EnumScriptType.PICKUP, event); return NpcAPI.EVENT_BUS.post(event); } - public static void onPlayerContainerOpen(PlayerDataScript handler, ScriptPlayer player, Container container) { + public static void onPlayerContainerOpen(PlayerDataScript handler, IPlayer player, Container container) { ContainerOpen event = new ContainerOpen(player, NpcAPI.Instance().getIContainer(container)); handler.callScript(EnumScriptType.CONTAINER_OPEN, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPlayerUseHoe(PlayerDataScript handler, ScriptPlayer player, ItemStack hoe, int x, int y, int z) { + public static void onPlayerUseHoe(PlayerDataScript handler, IPlayer player, ItemStack hoe, int x, int y, int z) { noppes.npcs.scripted.event.PlayerEvent.UseHoe event = new noppes.npcs.scripted.event.PlayerEvent.UseHoe(player, hoe, x, y, z); handler.callScript(EnumScriptType.USE_HOE, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPlayerSleep(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z) { + public static void onPlayerSleep(PlayerDataScript handler, IPlayer player, int x, int y, int z) { noppes.npcs.scripted.event.PlayerEvent.Sleep event = new noppes.npcs.scripted.event.PlayerEvent.Sleep(player, x, y, z); handler.callScript(EnumScriptType.SLEEP, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPlayerWakeUp(PlayerDataScript handler, ScriptPlayer player, boolean setSpawn) { + public static void onPlayerWakeUp(PlayerDataScript handler, IPlayer player, boolean setSpawn) { noppes.npcs.scripted.event.PlayerEvent.WakeUp event = new noppes.npcs.scripted.event.PlayerEvent.WakeUp(player, setSpawn); handler.callScript(EnumScriptType.WAKE_UP, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPlayerDeath(PlayerDataScript handler, ScriptPlayer player, DamageSource source, Entity entity) { + public static void onPlayerDeath(PlayerDataScript handler, IPlayer player, DamageSource source, Entity entity) { noppes.npcs.scripted.event.PlayerEvent.DiedEvent event = new noppes.npcs.scripted.event.PlayerEvent.DiedEvent(player, source, entity); handler.callScript(EnumScriptType.KILLED, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPlayerKills(PlayerDataScript handler, ScriptPlayer player, EntityLivingBase entityLiving) { + public static void onPlayerKills(PlayerDataScript handler, IPlayer player, EntityLivingBase entityLiving) { noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent event = new noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent(player, entityLiving); handler.callScript(EnumScriptType.KILLS, event); NpcAPI.EVENT_BUS.post(event); @@ -371,61 +368,61 @@ public class EventHooks { return NpcAPI.EVENT_BUS.post(event); } - public static boolean onPlayerLightning(PlayerDataScript handler, ScriptPlayer player) { + public static boolean onPlayerLightning(PlayerDataScript handler, IPlayer player) { PlayerEvent.LightningEvent event = new PlayerEvent.LightningEvent(player); handler.callScript(EnumScriptType.LIGHTNING, event); return NpcAPI.EVENT_BUS.post(event); } - public static boolean onPlayerSound(PlayerDataScript handler, ScriptPlayer player, String name, float pitch, float volume) { + public static boolean onPlayerSound(PlayerDataScript handler, IPlayer player, String name, float pitch, float volume) { PlayerEvent.SoundEvent event = new PlayerEvent.SoundEvent(player, name, pitch, volume); handler.callScript(EnumScriptType.PLAYSOUND, event); return NpcAPI.EVENT_BUS.post(event); } - public static void onPlayerFall(PlayerDataScript handler, ScriptPlayer player, float distance) { + public static void onPlayerFall(PlayerDataScript handler, IPlayer player, float distance) { PlayerEvent.FallEvent event = new PlayerEvent.FallEvent(player,distance); handler.callScript(EnumScriptType.FALL, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPlayerJump(PlayerDataScript handler, ScriptPlayer player) { + public static void onPlayerJump(PlayerDataScript handler, IPlayer player) { PlayerEvent.JumpEvent event = new PlayerEvent.JumpEvent(player); handler.callScript(EnumScriptType.JUMP, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPlayerLogin(PlayerDataScript handler, ScriptPlayer player) { + public static void onPlayerLogin(PlayerDataScript handler, IPlayer player) { LoginEvent event = new LoginEvent(player); handler.callScript(EnumScriptType.LOGIN, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPlayerAchievement(PlayerDataScript handler, ScriptPlayer player, String description) { + public static void onPlayerAchievement(PlayerDataScript handler, IPlayer player, String description) { PlayerEvent.Achievement event = new PlayerEvent.Achievement(player, description); handler.callScript(EnumScriptType.ACHIEVEMENT, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPlayerFillBucket(PlayerDataScript handler, ScriptPlayer player, ItemStack current, ItemStack result) { + public static void onPlayerFillBucket(PlayerDataScript handler, IPlayer player, ItemStack current, ItemStack result) { PlayerEvent.FillBucket event = new PlayerEvent.FillBucket(player, current, result); handler.callScript(EnumScriptType.FILL_BUCKET, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPlayerBonemeal(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z, World world) { + public static void onPlayerBonemeal(PlayerDataScript handler, IPlayer player, int x, int y, int z, World world) { PlayerEvent.Bonemeal event = new PlayerEvent.Bonemeal(player, x, y, z, world); handler.callScript(EnumScriptType.BONEMEAL, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPlayerRespawn(PlayerDataScript handler, ScriptPlayer player) { + public static void onPlayerRespawn(PlayerDataScript handler, IPlayer player) { PlayerEvent.RespawnEvent event = new PlayerEvent.RespawnEvent(player); handler.callScript(EnumScriptType.RESPAWN, event); NpcAPI.EVENT_BUS.post(event); } - public static void onPlayerLogout(PlayerDataScript handler, ScriptPlayer player) { + public static void onPlayerLogout(PlayerDataScript handler, IPlayer player) { LogoutEvent event = new LogoutEvent(player); handler.callScript(EnumScriptType.LOGOUT, event); NpcAPI.EVENT_BUS.post(event); @@ -451,7 +448,7 @@ public class EventHooks { return NpcAPI.EVENT_BUS.post(event); } - public static void onPlayerChangeDim(PlayerDataScript handler, ScriptPlayer player, int fromDim, int toDim) { + public static void onPlayerChangeDim(PlayerDataScript handler, IPlayer player, int fromDim, int toDim) { PlayerEvent.ChangedDimension event = new PlayerEvent.ChangedDimension(player, fromDim, toDim); handler.callScript(EnumScriptType.CHANGED_DIM, event); NpcAPI.EVENT_BUS.post(event); @@ -459,21 +456,21 @@ public class EventHooks { public static void onPlayerMouseClicked(EntityPlayerMP player, int button, int mouseWheel, boolean buttonDown) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, mouseWheel, buttonDown); + PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((IPlayer)NpcAPI.Instance().getIEntity(player), button, mouseWheel, buttonDown); handler.callScript(EnumScriptType.MOUSE_CLICKED, event); NpcAPI.EVENT_BUS.post(event); } public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean buttonDown, int[] heldKeys) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - KeyPressedEvent event = new KeyPressedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown, heldKeys); + KeyPressedEvent event = new KeyPressedEvent((IPlayer)NpcAPI.Instance().getIEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown, heldKeys); handler.callScript(EnumScriptType.KEY_PRESSED, event); NpcAPI.EVENT_BUS.post(event); } public static void onPlayerTimer(PlayerData data, int id) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(data.player), id); + noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent((IPlayer)NpcAPI.Instance().getIEntity(data.player), id); handler.callScript(EnumScriptType.TIMER, event); NpcAPI.EVENT_BUS.post(event); } @@ -484,7 +481,7 @@ public class EventHooks { } public static void onForgeEntityEvent(EntityEvent event) { - IEntity e = ScriptController.Instance.getScriptForEntity(event.entity); + IEntity e = NpcAPI.Instance().getIEntity(event.entity); onForgeEvent(new noppes.npcs.scripted.event.ForgeEvent.EntityEvent(event, e), event); } @@ -520,41 +517,41 @@ public class EventHooks { } } - public static void onCustomGuiButton(ScriptPlayer player, ICustomGui gui, int buttonId) { + public static void onCustomGuiButton(IPlayer player, ICustomGui gui, int buttonId) { CustomGuiEvent.ButtonEvent event = new CustomGuiEvent.ButtonEvent(player, gui, buttonId); CustomGuiController.onButton(event); } - public static void onCustomGuiSlot(ScriptPlayer player, ICustomGui gui, int slotId) { + public static void onCustomGuiSlot(IPlayer player, ICustomGui gui, int slotId) { CustomGuiEvent.SlotEvent event = new CustomGuiEvent.SlotEvent(player, gui, slotId, player.getOpenContainer().getSlot(slotId)); CustomGuiController.onSlotChange(event); } - public static void onCustomGuiUnfocused(ScriptPlayer player, ICustomGui gui, int textfieldId) { + public static void onCustomGuiUnfocused(IPlayer player, ICustomGui gui, int textfieldId) { CustomGuiEvent.UnfocusedEvent event = new CustomGuiEvent.UnfocusedEvent(player, gui, textfieldId); CustomGuiController.onCustomGuiUnfocused(event); } - public static void onCustomGuiScrollClick(ScriptPlayer player, ICustomGui gui, int scrollId, int scrollIndex, String[] selection, boolean doubleClick) { + public static void onCustomGuiScrollClick(IPlayer player, ICustomGui gui, int scrollId, int scrollIndex, String[] selection, boolean doubleClick) { CustomGuiEvent.ScrollEvent event = new CustomGuiEvent.ScrollEvent(player, gui, scrollId, scrollIndex, selection, doubleClick); CustomGuiController.onScrollClick(event); } - public static void onCustomGuiClose(ScriptPlayer player, ICustomGui gui) { + public static void onCustomGuiClose(IPlayer player, ICustomGui gui) { noppes.npcs.scripted.event.CustomGuiEvent.CloseEvent event = new noppes.npcs.scripted.event.CustomGuiEvent.CloseEvent(player, gui); CustomGuiController.onClose(event); } public static void onQuestFinished(EntityPlayer player, Quest quest){ PlayerDataScript handler = ScriptController.Instance.playerScripts; - QuestEvent.QuestCompletedEvent event = new QuestEvent.QuestCompletedEvent(new ScriptPlayer((EntityPlayerMP) player), quest); + QuestEvent.QuestCompletedEvent event = new QuestEvent.QuestCompletedEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), quest); handler.callScript(EnumScriptType.QUEST_COMPLETED, event); NpcAPI.EVENT_BUS.post(event); } public static boolean onQuestStarted(EntityPlayer player, Quest quest){ PlayerDataScript handler = ScriptController.Instance.playerScripts; - QuestEvent.QuestStartEvent event = new QuestEvent.QuestStartEvent(new ScriptPlayer((EntityPlayerMP) player), quest); + QuestEvent.QuestStartEvent event = new QuestEvent.QuestStartEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), quest); handler.callScript(EnumScriptType.QUEST_START, event); return NpcAPI.EVENT_BUS.post(event); } diff --git a/src/main/java/noppes/npcs/NoppesUtilPlayer.java b/src/main/java/noppes/npcs/NoppesUtilPlayer.java index eb5066ecd..80af8a0d3 100644 --- a/src/main/java/noppes/npcs/NoppesUtilPlayer.java +++ b/src/main/java/noppes/npcs/NoppesUtilPlayer.java @@ -29,11 +29,11 @@ import noppes.npcs.controllers.*; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleFollower; import cpw.mods.fml.common.network.internal.FMLProxyPacket; -import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.event.DialogEvent; import noppes.npcs.scripted.event.QuestEvent; +import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.item.IItemStack; -import noppes.npcs.scripted.wrapper.NpcAPI; +import noppes.npcs.scripted.NpcAPI; public class NoppesUtilPlayer { @@ -255,16 +255,16 @@ public class NoppesUtilPlayer { if(dialog == null) return; - EventHooks.onDialogOption(new DialogEvent.DialogOption(new ScriptPlayer((EntityPlayerMP) player), dialog)); + EventHooks.onDialogOption(new DialogEvent.DialogOption((IPlayer) NpcAPI.Instance().getIEntity(player), dialog)); EventHooks.onNPCDialogClosed(npc,player,dialogId,optionId+1,dialog); if(!dialog.hasDialogs(player) && !dialog.hasOtherOptions()) { - EventHooks.onDialogClosed(new DialogEvent.DialogClosed(new ScriptPlayer((EntityPlayerMP) player), dialog)); + EventHooks.onDialogClosed(new DialogEvent.DialogClosed((IPlayer) NpcAPI.Instance().getIEntity(player), dialog)); return; } DialogOption option = dialog.options.get(optionId); if(option == null || option.optionType == EnumOptionType.DialogOption && (!option.isAvailable(player) || !option.hasDialog()) || option.optionType == EnumOptionType.Disabled || option.optionType == EnumOptionType.QuitOption) { - EventHooks.onDialogClosed(new DialogEvent.DialogClosed(new ScriptPlayer((EntityPlayerMP) player), dialog)); + EventHooks.onDialogClosed(new DialogEvent.DialogClosed((IPlayer) NpcAPI.Instance().getIEntity(player), dialog)); return; } if(option.optionType == EnumOptionType.RoleOption){ @@ -302,7 +302,7 @@ public class NoppesUtilPlayer { if(!data.quest.questInterface.isCompleted(playerData)) return; - QuestEvent.QuestTurnedInEvent event = new QuestEvent.QuestTurnedInEvent(new ScriptPlayer(player), data.quest); + QuestEvent.QuestTurnedInEvent event = new QuestEvent.QuestTurnedInEvent((IPlayer) NpcAPI.Instance().getIEntity(player), data.quest); event.expReward = data.quest.rewardExp; List list = new ArrayList(); diff --git a/src/main/java/noppes/npcs/NoppesUtilServer.java b/src/main/java/noppes/npcs/NoppesUtilServer.java index 9940ec7b8..53e451fde 100644 --- a/src/main/java/noppes/npcs/NoppesUtilServer.java +++ b/src/main/java/noppes/npcs/NoppesUtilServer.java @@ -72,9 +72,9 @@ import noppes.npcs.controllers.TransportLocation; import noppes.npcs.entity.EntityDialogNpc; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleTransporter; -import noppes.npcs.scripted.entity.ScriptPlayer; +import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.event.DialogEvent; -import noppes.npcs.scripted.event.ScriptEventDialog; +import noppes.npcs.scripted.interfaces.entity.IPlayer; public class NoppesUtilServer { private static HashMap editingQuests = new HashMap(); @@ -183,7 +183,7 @@ public class NoppesUtilServer { public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia, int optionId){ Dialog dialog = dia.copy(player); - EventHooks.onDialogOpen(new DialogEvent.DialogOpen(new ScriptPlayer((EntityPlayerMP) player), dialog)); + EventHooks.onDialogOpen(new DialogEvent.DialogOpen((IPlayer) NpcAPI.Instance().getIEntity(player), dialog)); if(npc instanceof EntityDialogNpc){ dialog.hideNPC = true; diff --git a/src/main/java/noppes/npcs/PacketHandlerServer.java b/src/main/java/noppes/npcs/PacketHandlerServer.java index 18892ed2c..8e7a5f64b 100644 --- a/src/main/java/noppes/npcs/PacketHandlerServer.java +++ b/src/main/java/noppes/npcs/PacketHandlerServer.java @@ -51,8 +51,9 @@ import noppes.npcs.roles.RoleTrader; import noppes.npcs.roles.RoleTransporter; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent; -import noppes.npcs.scripted.entity.ScriptPlayer; +import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.gui.ScriptGui; +import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.item.ScriptCustomItem; public class PacketHandlerServer{ @@ -78,22 +79,22 @@ public class PacketHandlerServer{ return; } else if (type == EnumPacketServer.CustomGuiButton && player.openContainer instanceof ContainerCustomGui) { ((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer)); - EventHooks.onCustomGuiButton((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt()); + EventHooks.onCustomGuiButton((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt()); return; } else if (type == EnumPacketServer.CustomGuiSlotChange && player.openContainer instanceof ContainerCustomGui) { ((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer)); - EventHooks.onCustomGuiSlot((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt()); + EventHooks.onCustomGuiSlot((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt()); return; } else if(type == EnumPacketServer.CustomGuiUnfocused && player.openContainer instanceof ContainerCustomGui) { ((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer)); - EventHooks.onCustomGuiUnfocused((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt()); + EventHooks.onCustomGuiUnfocused((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt()); return; } else if (type == EnumPacketServer.CustomGuiScrollClick && player.openContainer instanceof ContainerCustomGui) { ((ContainerCustomGui) player.openContainer).customGui.fromNBT(Server.readNBT(buffer)); - EventHooks.onCustomGuiScrollClick((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt(), buffer.readInt(), CustomGuiController.readScrollSelection(buffer), buffer.readBoolean()); + EventHooks.onCustomGuiScrollClick((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt(), buffer.readInt(), CustomGuiController.readScrollSelection(buffer), buffer.readBoolean()); return; } else if (type == EnumPacketServer.CustomGuiClose) { - EventHooks.onCustomGuiClose((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer))); + EventHooks.onCustomGuiClose((IPlayer) NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer))); return; } diff --git a/src/main/java/noppes/npcs/ScriptItemEventHandler.java b/src/main/java/noppes/npcs/ScriptItemEventHandler.java index c460cb80c..cab2563b6 100644 --- a/src/main/java/noppes/npcs/ScriptItemEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptItemEventHandler.java @@ -12,15 +12,13 @@ import net.minecraftforge.event.entity.item.ItemTossEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.player.EntityInteractEvent; import net.minecraftforge.event.entity.player.PlayerUseItemEvent; -import noppes.npcs.controllers.ScriptController; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.items.ItemScripted; -import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.event.ItemEvent; +import noppes.npcs.scripted.interfaces.item.IItemCustom; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.entity.IPlayer; -import noppes.npcs.scripted.item.ScriptCustomItem; -import noppes.npcs.scripted.wrapper.NpcAPI; +import noppes.npcs.scripted.NpcAPI; import java.util.HashMap; @@ -42,13 +40,13 @@ public class ScriptItemEventHandler { for (ItemStack stack : inventory.values()) { if (stack != null && stack.getItem() == CustomItems.scripted_item) { IItemStack istack = NpcAPI.Instance().getIItemStack(stack); - EventHooks.onScriptItemUpdate((ScriptCustomItem) istack, event.entityLiving); + EventHooks.onScriptItemUpdate((IItemCustom) istack, event.entityLiving); } } } } else if(event.entityLiving.getHeldItem() != null && event.entityLiving.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) { IItemStack itemStack = NpcAPI.Instance().getIItemStack(event.entityLiving.getHeldItem()); - EventHooks.onScriptItemUpdate((ScriptCustomItem) itemStack, event.entityLiving); + EventHooks.onScriptItemUpdate((IItemCustom) itemStack, event.entityLiving); } } @@ -60,7 +58,7 @@ public class ScriptItemEventHandler { if(event.player.worldObj instanceof WorldServer) { try { if (event.entityItem.getEntityItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) { - ScriptCustomItem isw = ItemScripted.GetWrapper(event.entityItem.getEntityItem()); + IItemCustom isw = ItemScripted.GetWrapper(event.entityItem.getEntityItem()); EventHooks.onScriptItemTossed(isw, event.player, event.entityItem); } } catch (Exception e) {} @@ -75,7 +73,7 @@ public class ScriptItemEventHandler { if(event.player.worldObj instanceof WorldServer) { try { if (event.player.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) { - ScriptCustomItem isw = ItemScripted.GetWrapper(event.player.getHeldItem()); + IItemCustom isw = ItemScripted.GetWrapper(event.player.getHeldItem()); EventHooks.onScriptItemPickedUp(isw, event.player); } } catch(Exception e) {} @@ -104,8 +102,8 @@ public class ScriptItemEventHandler { if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { try { if (event.entityPlayer.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) { - ScriptCustomItem isw = ItemScripted.GetWrapper(event.entityPlayer.getHeldItem()); - ItemEvent.InteractEvent eve = new ItemEvent.InteractEvent(isw, (IPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer), 2, NpcAPI.Instance().getIBlock(event.entityPlayer.worldObj, new BlockPos(event.entityPlayer.posX, event.entityPlayer.posY, event.entityPlayer.posZ))); + IItemCustom isw = ItemScripted.GetWrapper(event.entityPlayer.getHeldItem()); + ItemEvent.InteractEvent eve = new ItemEvent.InteractEvent(isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 2, NpcAPI.Instance().getIBlock(event.entityPlayer.worldObj, new BlockPos(event.entityPlayer.posX, event.entityPlayer.posY, event.entityPlayer.posZ))); event.setCanceled(EventHooks.onScriptItemInteract(isw, eve)); } } catch(Exception e) {} @@ -118,9 +116,9 @@ public class ScriptItemEventHandler { return; if(event.entityPlayer.worldObj instanceof WorldServer) { - ScriptCustomItem handler = ItemScripted.GetWrapper(event.item); - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); - event.setCanceled(EventHooks.onStartUsingCustomItem(handler, scriptPlayer, event.duration)); + IItemCustom handler = ItemScripted.GetWrapper(event.item); + IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); + event.setCanceled(EventHooks.onStartUsingCustomItem(handler, IPlayer, event.duration)); } } @SubscribeEvent @@ -129,9 +127,9 @@ public class ScriptItemEventHandler { return; if(event.entityPlayer.worldObj instanceof WorldServer && event.item.getItem() == CustomItems.scripted_item) { - ScriptCustomItem handler = ItemScripted.GetWrapper(event.item); - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); - event.setCanceled(EventHooks.onUsingCustomItem(handler, scriptPlayer, event.duration)); + IItemCustom handler = ItemScripted.GetWrapper(event.item); + IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); + event.setCanceled(EventHooks.onUsingCustomItem(handler, IPlayer, event.duration)); } } @SubscribeEvent @@ -140,9 +138,9 @@ public class ScriptItemEventHandler { return; if(event.entityPlayer.worldObj instanceof WorldServer && event.item.getItem() == CustomItems.scripted_item) { - ScriptCustomItem handler = ItemScripted.GetWrapper(event.item); - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); - event.setCanceled(EventHooks.onStopUsingCustomItem(handler, scriptPlayer, event.duration)); + IItemCustom handler = ItemScripted.GetWrapper(event.item); + IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); + event.setCanceled(EventHooks.onStopUsingCustomItem(handler, IPlayer, event.duration)); } } @SubscribeEvent @@ -151,9 +149,9 @@ public class ScriptItemEventHandler { return; if(event.entityPlayer.worldObj instanceof WorldServer && event.item.getItem() == CustomItems.scripted_item) { - ScriptCustomItem handler = ItemScripted.GetWrapper(event.item); - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); - EventHooks.onFinishUsingCustomItem(handler, scriptPlayer, event.duration); + IItemCustom handler = ItemScripted.GetWrapper(event.item); + IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); + EventHooks.onFinishUsingCustomItem(handler, IPlayer, event.duration); } } } diff --git a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java index 0257001a4..97962af24 100644 --- a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java @@ -30,8 +30,8 @@ import noppes.npcs.constants.EnumQuestType; import noppes.npcs.controllers.*; import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.entity.EntityNPCInterface; -import noppes.npcs.scripted.entity.ScriptPlayer; -import noppes.npcs.scripted.wrapper.NpcAPI; +import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.interfaces.entity.IPlayer; public class ScriptPlayerEventHandler { public ScriptPlayerEventHandler() { @@ -46,7 +46,7 @@ public class ScriptPlayerEventHandler { if(player.ticksExisted%10 == 0) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(player); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(player); EventHooks.onPlayerTick(handler, scriptPlayer); } @@ -71,8 +71,8 @@ public class ScriptPlayerEventHandler { if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); - noppes.npcs.scripted.event.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.PlayerEvent.InteractEvent(scriptPlayer, 1, ScriptController.Instance.getScriptForEntity(event.target)); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); + noppes.npcs.scripted.event.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.PlayerEvent.InteractEvent(scriptPlayer, 1, NpcAPI.Instance().getIEntity(event.target)); event.setCanceled(EventHooks.onPlayerInteract(handler, ev)); } } @@ -84,7 +84,7 @@ public class ScriptPlayerEventHandler { if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent(scriptPlayer); EventHooks.onPlayerBowCharge(handler, ev); } @@ -97,7 +97,7 @@ public class ScriptPlayerEventHandler { if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent(scriptPlayer, event.bow, event.charge); EventHooks.onPlayerRanged(handler, ev); } @@ -110,7 +110,7 @@ public class ScriptPlayerEventHandler { if(!event.getPlayer().worldObj.isRemote && event.world instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.getPlayer()); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.getPlayer()); noppes.npcs.scripted.event.PlayerEvent.BreakEvent ev = new noppes.npcs.scripted.event.PlayerEvent.BreakEvent(scriptPlayer, NpcAPI.Instance().getIBlock(event.world, new BlockPos(event.x,event.y,event.z)), event.getExpToDrop()); event.setCanceled(EventHooks.onPlayerBreak(handler, ev)); event.setExpToDrop(ev.exp); @@ -124,7 +124,7 @@ public class ScriptPlayerEventHandler { if(event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); event.setCanceled(EventHooks.onStartUsingItem(handler, scriptPlayer, event.duration, event.item)); } } @@ -135,7 +135,7 @@ public class ScriptPlayerEventHandler { if(event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); event.setCanceled(EventHooks.onUsingItem(handler, scriptPlayer, event.duration, event.item)); } } @@ -146,7 +146,7 @@ public class ScriptPlayerEventHandler { if(event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); event.setCanceled(EventHooks.onStopUsingItem(handler, scriptPlayer, event.duration, event.item)); } } @@ -157,7 +157,7 @@ public class ScriptPlayerEventHandler { if(event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onFinishUsingItem(handler, scriptPlayer, event.duration, event.item); } } @@ -169,7 +169,7 @@ public class ScriptPlayerEventHandler { if(event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); event.setCanceled(EventHooks.onPlayerDropItems(handler, scriptPlayer, event.drops)); } } @@ -181,7 +181,7 @@ public class ScriptPlayerEventHandler { if(event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerPickupXP(handler, scriptPlayer, event.orb); } } @@ -193,7 +193,7 @@ public class ScriptPlayerEventHandler { if(event.player.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerChangeDim(handler, scriptPlayer, event.fromDim, event.toDim); } } @@ -205,7 +205,7 @@ public class ScriptPlayerEventHandler { if(event.player.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerPickUp(handler, scriptPlayer, event.pickedUp); } } @@ -217,7 +217,7 @@ public class ScriptPlayerEventHandler { if(event.entityPlayer.worldObj instanceof WorldServer && !(event.entityPlayer.openContainer instanceof ContainerPlayer)) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerContainerOpen(handler, scriptPlayer, event.entityPlayer.openContainer); } } @@ -229,7 +229,7 @@ public class ScriptPlayerEventHandler { if(event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerUseHoe(handler, scriptPlayer, event.current, event.x, event.y, event.z); } } @@ -241,7 +241,7 @@ public class ScriptPlayerEventHandler { if(event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerSleep(handler, scriptPlayer, event.x, event.y, event.z); } } @@ -253,7 +253,7 @@ public class ScriptPlayerEventHandler { if(event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerWakeUp(handler, scriptPlayer, event.setSpawn); } } @@ -265,7 +265,7 @@ public class ScriptPlayerEventHandler { if(event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerFillBucket(handler, scriptPlayer, event.current, event.result); } } @@ -277,7 +277,7 @@ public class ScriptPlayerEventHandler { if(event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerBonemeal(handler, scriptPlayer, event.x, event.y, event.z, event.world); } } @@ -289,7 +289,7 @@ public class ScriptPlayerEventHandler { if(event.entityPlayer.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer); EventHooks.onPlayerAchievement(handler, scriptPlayer, CustomNpcs.proxy.getAchievementDesc(event.achievement)); } } @@ -301,7 +301,7 @@ public class ScriptPlayerEventHandler { if(event.player.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem); } } @@ -314,7 +314,7 @@ public class ScriptPlayerEventHandler { if(event.entityLiving.worldObj instanceof WorldServer) { if (event.entityLiving instanceof EntityPlayer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving); EventHooks.onPlayerFall(handler, scriptPlayer, event.distance); } } @@ -328,7 +328,7 @@ public class ScriptPlayerEventHandler { if(event.entityLiving.worldObj instanceof WorldServer) { if (event.entityLiving instanceof EntityPlayer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving); EventHooks.onPlayerJump(handler, scriptPlayer); } } @@ -342,7 +342,7 @@ public class ScriptPlayerEventHandler { if(event.entity.worldObj instanceof WorldServer) { if (event.entity instanceof EntityPlayer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entity); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entity); EventHooks.onPlayerLightning(handler, scriptPlayer); } } @@ -356,7 +356,7 @@ public class ScriptPlayerEventHandler { if(event.entity.worldObj instanceof WorldServer) { if (event.entity instanceof EntityPlayer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entity); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entity); EventHooks.onPlayerSound(handler,scriptPlayer,event.name,event.pitch,event.volume); } } @@ -371,12 +371,12 @@ public class ScriptPlayerEventHandler { Entity source = NoppesUtilServer.GetDamageSourcee(event.source); PlayerDataScript handler = ScriptController.Instance.playerScripts; if(event.entityLiving instanceof EntityPlayer) { - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving); EventHooks.onPlayerDeath(handler,scriptPlayer, event.source, source); } if(source instanceof EntityPlayer) { - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.source.getEntity()); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.source.getEntity()); EventHooks.onPlayerKills(handler,scriptPlayer, event.entityLiving); } @@ -392,13 +392,13 @@ public class ScriptPlayerEventHandler { Entity source = NoppesUtilServer.GetDamageSourcee(event.source); PlayerDataScript handler = ScriptController.Instance.playerScripts; if(event.entityLiving instanceof EntityPlayer) { - noppes.npcs.scripted.event.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.DamagedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity((EntityPlayer)event.entityLiving), source, event.ammount, event.source); + noppes.npcs.scripted.event.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.DamagedEvent((IPlayer)NpcAPI.Instance().getIEntity((EntityPlayer)event.entityLiving), source, event.ammount, event.source); event.setCanceled(EventHooks.onPlayerDamaged(handler, pevent)); event.ammount = pevent.damage; } if(source instanceof EntityPlayer) { - noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, event.ammount, event.source); + noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((IPlayer)NpcAPI.Instance().getIEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, event.ammount, event.source); event.setCanceled(EventHooks.onPlayerDamagedEntity(handler, pevent1)); event.ammount = pevent1.damage; } @@ -412,7 +412,7 @@ public class ScriptPlayerEventHandler { if(event.player.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerRespawn(handler, scriptPlayer); } } @@ -424,7 +424,7 @@ public class ScriptPlayerEventHandler { if(event.player.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerLogin(handler, scriptPlayer); } } @@ -436,7 +436,7 @@ public class ScriptPlayerEventHandler { if(event.player.worldObj instanceof WorldServer) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerLogout(handler, scriptPlayer); } } @@ -450,7 +450,7 @@ public class ScriptPlayerEventHandler { if(event.player.worldObj instanceof WorldServer && !event.player.equals(EntityNPCInterface.chateventPlayer)) { PlayerDataScript handler = ScriptController.Instance.playerScripts; - ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player); + IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); String message = event.message; noppes.npcs.scripted.event.PlayerEvent.ChatEvent ev = new noppes.npcs.scripted.event.PlayerEvent.ChatEvent(scriptPlayer, event.message); EventHooks.onPlayerChat(handler, ev); diff --git a/src/main/java/noppes/npcs/client/renderer/CustomItemRenderer.java b/src/main/java/noppes/npcs/client/renderer/CustomItemRenderer.java index 488ecc496..2f8a32ea5 100644 --- a/src/main/java/noppes/npcs/client/renderer/CustomItemRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/CustomItemRenderer.java @@ -13,6 +13,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; +import noppes.npcs.CustomItems; import noppes.npcs.items.ItemRenderInterface; import noppes.npcs.items.ItemScripted; import noppes.npcs.scripted.item.ScriptCustomItem; @@ -104,7 +105,7 @@ public class CustomItemRenderer implements IItemRenderer { GL11.glTranslatef(0.9375F, 0.0625F, 0.0F); GL11.glRotatef(-315.0F, 0.0F, 0.0F, 1.0F); - ((ItemRenderInterface) itemStack.getItem()).renderSpecial(); + ((ItemScripted) itemStack.getItem()).renderOffset(scriptCustomItem); GL11.glTranslatef(scriptCustomItem.translateX, scriptCustomItem.translateY, scriptCustomItem.translateZ); GL11.glRotatef(scriptCustomItem.rotationX, 1, 0, 0); GL11.glRotatef(scriptCustomItem.rotationY, 0, 1, 0); diff --git a/src/main/java/noppes/npcs/controllers/CustomGuiController.java b/src/main/java/noppes/npcs/controllers/CustomGuiController.java index 53d36a672..05451aa73 100644 --- a/src/main/java/noppes/npcs/controllers/CustomGuiController.java +++ b/src/main/java/noppes/npcs/controllers/CustomGuiController.java @@ -10,12 +10,12 @@ import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumScriptType; import noppes.npcs.containers.ContainerCustomGui; -import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.event.CustomGuiEvent; import noppes.npcs.scripted.gui.ScriptGui; +import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.overlay.ScriptOverlay; -import noppes.npcs.scripted.wrapper.NpcAPI; +import noppes.npcs.scripted.NpcAPI; import java.io.IOException; @@ -23,14 +23,14 @@ public class CustomGuiController { public CustomGuiController() { } - public static void openGui(ScriptPlayer player, ScriptGui gui) { + public static void openGui(IPlayer player, ScriptGui gui) { EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player.getMCEntity(); entityPlayerMP.openGui(CustomNpcs.instance, EnumGuiType.CustomGui.ordinal(), player.getWorld().getMCWorld(), gui.getSlots().size(), 0, 0); ((ContainerCustomGui)((EntityPlayerMP)player.getMCEntity()).openContainer).setGui(gui, (EntityPlayer)player.getMCEntity()); Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.GUI_DATA, new Object[]{gui.toNBT()}); } - public static boolean updateGui(ScriptPlayer player, ScriptGui gui) { + public static boolean updateGui(IPlayer player, ScriptGui gui) { if (((EntityPlayerMP)player.getMCEntity()).openContainer instanceof ContainerCustomGui) { Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.GUI_DATA, new Object[]{gui.toNBT()}); return true; @@ -39,11 +39,11 @@ public class CustomGuiController { } } - public static void openOverlay(ScriptPlayer player, ScriptOverlay gui) { + public static void openOverlay(IPlayer player, ScriptOverlay gui) { Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.OVERLAY_DATA, new Object[]{gui.toNBT()}); } - public static boolean updateOverlay(ScriptPlayer player, ScriptOverlay gui) { + public static boolean updateOverlay(IPlayer player, ScriptOverlay gui) { Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.OVERLAY_DATA, new Object[]{gui.toNBT()}); return true; } diff --git a/src/main/java/noppes/npcs/controllers/FactionOptions.java b/src/main/java/noppes/npcs/controllers/FactionOptions.java index 9e07aef0e..2ab6351c5 100644 --- a/src/main/java/noppes/npcs/controllers/FactionOptions.java +++ b/src/main/java/noppes/npcs/controllers/FactionOptions.java @@ -1,12 +1,8 @@ package noppes.npcs.controllers; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentTranslation; -import noppes.npcs.EventHooks; -import noppes.npcs.scripted.entity.ScriptPlayer; -import noppes.npcs.scripted.event.FactionEvent; public class FactionOptions { diff --git a/src/main/java/noppes/npcs/controllers/PlayerFactionData.java b/src/main/java/noppes/npcs/controllers/PlayerFactionData.java index 3455f4bf6..f98afc038 100644 --- a/src/main/java/noppes/npcs/controllers/PlayerFactionData.java +++ b/src/main/java/noppes/npcs/controllers/PlayerFactionData.java @@ -7,8 +7,9 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.EventHooks; -import noppes.npcs.scripted.entity.ScriptPlayer; +import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.event.FactionEvent; +import noppes.npcs.scripted.interfaces.entity.IPlayer; public class PlayerFactionData { public HashMap factionData = new HashMap(); @@ -51,7 +52,7 @@ public class PlayerFactionData { } public void increasePoints(int factionId, int points, EntityPlayer player) { - EventHooks.onFactionPoints(new FactionEvent.FactionPoints(new ScriptPlayer((EntityPlayerMP) player), FactionController.getInstance().get(factionId), points < 0, points)); + EventHooks.onFactionPoints(new FactionEvent.FactionPoints((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), FactionController.getInstance().get(factionId), points < 0, points)); if(!factionData.containsKey(factionId)){ Faction faction = FactionController.getInstance().get(factionId); factionData.put(factionId, faction == null? -1 : faction.defaultPoints); diff --git a/src/main/java/noppes/npcs/controllers/Quest.java b/src/main/java/noppes/npcs/controllers/Quest.java index cdc92a150..1e079706b 100644 --- a/src/main/java/noppes/npcs/controllers/Quest.java +++ b/src/main/java/noppes/npcs/controllers/Quest.java @@ -23,7 +23,7 @@ import noppes.npcs.scripted.interfaces.handler.data.IQuestInterface; import noppes.npcs.scripted.interfaces.handler.data.IQuestObjective; import noppes.npcs.scripted.interfaces.IContainer; import noppes.npcs.scripted.interfaces.entity.IPlayer; -import noppes.npcs.scripted.wrapper.NpcAPI; +import noppes.npcs.scripted.NpcAPI; public class Quest implements ICompatibilty, IQuest { public int version = VersionCompatibility.ModRev; diff --git a/src/main/java/noppes/npcs/controllers/ScriptContainer.java b/src/main/java/noppes/npcs/controllers/ScriptContainer.java index 1cc4d8a9f..c5c4658f4 100644 --- a/src/main/java/noppes/npcs/controllers/ScriptContainer.java +++ b/src/main/java/noppes/npcs/controllers/ScriptContainer.java @@ -19,7 +19,7 @@ import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.CustomNpcs; import noppes.npcs.NBTTags; import noppes.npcs.constants.EnumScriptType; -import noppes.npcs.scripted.wrapper.NpcAPI; +import noppes.npcs.scripted.NpcAPI; public class ScriptContainer { private static final String lock = "lock"; diff --git a/src/main/java/noppes/npcs/controllers/ScriptController.java b/src/main/java/noppes/npcs/controllers/ScriptController.java index 7e7e7f36a..066ef7193 100644 --- a/src/main/java/noppes/npcs/controllers/ScriptController.java +++ b/src/main/java/noppes/npcs/controllers/ScriptController.java @@ -284,36 +284,8 @@ public class ScriptController { return list; } - public ScriptEntity getScriptForEntity(Entity entity) { - if(entity == null) - return null; - if(entity instanceof EntityNPCInterface) - return (ScriptNpc)((EntityNPCInterface) entity).script.dummyNpc; - else{ - ScriptEntityData data = (ScriptEntityData) entity.getExtendedProperties("ScriptedObject"); - if(data != null) - return data.base; - if(entity instanceof EntityPlayerMP) - data = new ScriptEntityData(new ScriptPlayer((EntityPlayerMP) entity)); - else if(PixelmonHelper.isPixelmon(entity)) - return new ScriptPixelmon((EntityTameable) entity); - else if(entity instanceof EntityAnimal) - data = new ScriptEntityData(new ScriptAnimal((EntityAnimal) entity)); - else if(entity instanceof EntityMob) - data = new ScriptEntityData(new ScriptMonster((EntityMob) entity)); - else if(entity instanceof EntityLiving) - data = new ScriptEntityData(new ScriptLiving((EntityLiving) entity)); - else if(entity instanceof EntityLivingBase) - data = new ScriptEntityData(new ScriptLivingBase((EntityLivingBase)entity)); - else - data = new ScriptEntityData(new ScriptEntity(entity)); - entity.registerExtendedProperties("ScriptedObject", data); - return data.base; - } - } - @SubscribeEvent - public void saveWorld(WorldEvent.Save event){ + public void invoke(WorldEvent.Save event){ if(!shouldSave || event.world.isRemote || event.world != MinecraftServer.getServer().worldServers[0]) return; diff --git a/src/main/java/noppes/npcs/controllers/ScriptEntityData.java b/src/main/java/noppes/npcs/controllers/ScriptEntityData.java index 08c4e152d..5fdda0019 100644 --- a/src/main/java/noppes/npcs/controllers/ScriptEntityData.java +++ b/src/main/java/noppes/npcs/controllers/ScriptEntityData.java @@ -4,13 +4,14 @@ import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.common.IExtendedEntityProperties; -import noppes.npcs.scripted.entity.ScriptEntity; +import noppes.npcs.scripted.interfaces.entity.IEntity; public class ScriptEntityData implements IExtendedEntityProperties{ - public ScriptEntity base; - public ScriptEntityData(ScriptEntity base){ + public IEntity base; + public ScriptEntityData(IEntity base){ this.base = base; } + @Override public void saveNBTData(NBTTagCompound compound) { } @@ -22,5 +23,4 @@ public class ScriptEntityData implements IExtendedEntityProperties{ @Override public void init(Entity entity, World world) { } - } diff --git a/src/main/java/noppes/npcs/controllers/ServerCloneController.java b/src/main/java/noppes/npcs/controllers/ServerCloneController.java index 0462de388..b3b30280e 100644 --- a/src/main/java/noppes/npcs/controllers/ServerCloneController.java +++ b/src/main/java/noppes/npcs/controllers/ServerCloneController.java @@ -18,6 +18,7 @@ import noppes.npcs.CustomNpcs; import noppes.npcs.LogWriter; import noppes.npcs.NoppesUtilServer; import noppes.npcs.scripted.CustomNPCsException; +import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.handler.ICloneHandler; import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.IWorld; @@ -199,7 +200,7 @@ public class ServerCloneController implements ICloneHandler { throw new CustomNPCsException("Unknown clone tab:" + tab + " name:" + name, new Object[0]); } else { Entity entity = NoppesUtilServer.spawnClone(compound, (int)x, (int)y, (int)z, world.getMCWorld()); - return entity == null ? null : ScriptController.Instance.getScriptForEntity(entity); + return entity == null ? null : NpcAPI.Instance().getIEntity(entity); } } @@ -210,7 +211,7 @@ public class ServerCloneController implements ICloneHandler { } else { Instance.cleanTags(compound); Entity entity = EntityList.createEntityFromNBT(compound, world.getMCWorld()); - return entity == null ? null : ScriptController.Instance.getScriptForEntity(entity); + return entity == null ? null : NpcAPI.Instance().getIEntity(entity); } } diff --git a/src/main/java/noppes/npcs/controllers/data/NPCDataScript.java b/src/main/java/noppes/npcs/controllers/data/NPCDataScript.java index bf291a73a..621a6877b 100644 --- a/src/main/java/noppes/npcs/controllers/data/NPCDataScript.java +++ b/src/main/java/noppes/npcs/controllers/data/NPCDataScript.java @@ -11,6 +11,7 @@ import noppes.npcs.controllers.IScriptHandler; import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.controllers.ScriptController; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import javax.annotation.CheckForNull; @@ -119,7 +120,7 @@ public class NPCDataScript implements IScriptHandler { } public ICustomNpc getNpc() { if (this.npcAPI == null) { - this.npcAPI = (ICustomNpc) ScriptController.Instance.getScriptForEntity(this.npc); + this.npcAPI = (ICustomNpc) NpcAPI.Instance().getIEntity(this.npc); } return this.npcAPI; } diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java b/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java index 60c916293..7f8ea2e60 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerDataScript.java @@ -18,7 +18,7 @@ import noppes.npcs.NBTTags; import noppes.npcs.constants.EnumScriptType; import noppes.npcs.controllers.IScriptHandler; import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.entity.ScriptPlayer; +import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.entity.IPlayer; import javax.annotation.CheckForNull; @@ -69,7 +69,7 @@ public class PlayerDataScript implements IScriptHandler { if (type != EnumScriptType.INIT) { noppes.npcs.scripted.event.PlayerEvent playerEvent = (noppes.npcs.scripted.event.PlayerEvent)event; - EventHooks.onPlayerInit(this, (ScriptPlayer) playerEvent.player); + EventHooks.onPlayerInit(this, playerEvent.player); } } @@ -133,7 +133,7 @@ public class PlayerDataScript implements IScriptHandler { } public IPlayer getPlayer() { if (this.playerAPI == null) { - this.playerAPI = (IPlayer) ScriptController.Instance.getScriptForEntity(this.player); + this.playerAPI = (IPlayer) NpcAPI.Instance().getIEntity(this.player); } return this.playerAPI; } diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index b6481e015..d01fd270a 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -80,6 +80,7 @@ import noppes.npcs.roles.JobInterface; import noppes.npcs.roles.RoleCompanion; import noppes.npcs.roles.RoleFollower; import noppes.npcs.roles.RoleInterface; +import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptNpc; import noppes.npcs.scripted.event.ScriptEventAttack; import noppes.npcs.scripted.event.ScriptEventDamaged; @@ -165,7 +166,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti this.updateTasks(); if (!this.isRemote()) { - this.wrappedNPC = new ScriptNpc(this); + this.wrappedNPC = new ScriptNpc<>(this); } } catch(Exception e){ diff --git a/src/main/java/noppes/npcs/items/ItemScripted.java b/src/main/java/noppes/npcs/items/ItemScripted.java index 4f8991bd2..3b4f0fdae 100644 --- a/src/main/java/noppes/npcs/items/ItemScripted.java +++ b/src/main/java/noppes/npcs/items/ItemScripted.java @@ -22,7 +22,7 @@ import noppes.npcs.controllers.ScriptController; import noppes.npcs.scripted.event.ItemEvent; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.item.ScriptCustomItem; -import noppes.npcs.scripted.wrapper.NpcAPI; +import noppes.npcs.scripted.NpcAPI; import org.lwjgl.opengl.GL11; public class ItemScripted extends Item implements ItemRenderInterface { @@ -75,7 +75,7 @@ public class ItemScripted extends Item implements ItemRenderInterface { return false; IItemStack istack = NpcAPI.Instance().getIItemStack(stack); - ItemEvent.AttackEvent eve = new ItemEvent.AttackEvent( (ScriptCustomItem) istack, ScriptController.Instance.getScriptForEntity(entityLivingBase), 2, null); + ItemEvent.AttackEvent eve = new ItemEvent.AttackEvent( (ScriptCustomItem) istack, NpcAPI.Instance().getIEntity(entityLivingBase), 2, null); return EventHooks.onScriptItemAttack((ScriptCustomItem) istack, eve); } @@ -132,7 +132,7 @@ public class ItemScripted extends Item implements ItemRenderInterface { public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { IItemStack istack = NpcAPI.Instance().getIItemStack(stack); - ItemEvent.AttackEvent eve = new ItemEvent.AttackEvent( (ScriptCustomItem) istack, ScriptController.Instance.getScriptForEntity(attacker), 1, ScriptController.Instance.getScriptForEntity(target)); + ItemEvent.AttackEvent eve = new ItemEvent.AttackEvent( (ScriptCustomItem) istack, NpcAPI.Instance().getIEntity(attacker), 1, NpcAPI.Instance().getIEntity(target)); return EventHooks.onScriptItemAttack((ScriptCustomItem) istack, eve); } @@ -157,7 +157,9 @@ public class ItemScripted extends Item implements ItemRenderInterface { } @Override - public void renderSpecial() { - GL11.glTranslatef(0.135F, 0.2F, 0.07F); + public void renderSpecial() {} + + public void renderOffset(ScriptCustomItem scriptCustomItem) { + GL11.glTranslatef(0.135F * scriptCustomItem.scaleX, 0.2F * scriptCustomItem.scaleY, 0.07F * scriptCustomItem.scaleZ); } } diff --git a/src/main/java/noppes/npcs/scripted/wrapper/NpcAPI.java b/src/main/java/noppes/npcs/scripted/NpcAPI.java similarity index 94% rename from src/main/java/noppes/npcs/scripted/wrapper/NpcAPI.java rename to src/main/java/noppes/npcs/scripted/NpcAPI.java index bebe92068..f4e2d012e 100644 --- a/src/main/java/noppes/npcs/scripted/wrapper/NpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/NpcAPI.java @@ -3,7 +3,7 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.wrapper; +package noppes.npcs.scripted; import java.io.File; import java.util.List; @@ -33,13 +33,12 @@ import noppes.npcs.CustomNpcs; import noppes.npcs.NoppesUtilServer; import noppes.npcs.controllers.*; import noppes.npcs.items.ItemScripted; -import noppes.npcs.scripted.*; import noppes.npcs.containers.ContainerNpcInterface; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; -import noppes.npcs.scripted.ScriptContainer; import noppes.npcs.scripted.entity.*; import noppes.npcs.scripted.gui.ScriptGui; +import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.handler.*; import noppes.npcs.scripted.interfaces.*; import noppes.npcs.scripted.interfaces.entity.ICustomNpc; @@ -47,6 +46,7 @@ import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.gui.ICustomGui; import noppes.npcs.scripted.interfaces.item.IItemCustom; import noppes.npcs.scripted.interfaces.item.IItemStack; +import noppes.npcs.scripted.interfaces.AbstractNpcAPI; import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay; import noppes.npcs.scripted.item.ScriptCustomItem; import noppes.npcs.scripted.item.ScriptItemStack; @@ -270,21 +270,21 @@ public class NpcAPI extends AbstractNpcAPI { return CustomNpcs.MARKOV_GENERATOR[dictionary].fetch(gender); } - public ScriptPlayer[] getAllServerPlayers(){ + public IPlayer[] getAllServerPlayers(){ List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; - ScriptPlayer[] arr = new ScriptPlayer[list.size()]; + IPlayer[] arr = new IPlayer[list.size()]; for(int i = 0; i < list.size(); i++){ - arr[i] = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(list.get(i)); + arr[i] = (IPlayer) NpcAPI.Instance().getIEntity(list.get(i)); } return arr; } - public void playSoundAtEntity(ScriptEntity entity, String sound, float volume, float pitch){ + public void playSoundAtEntity(IEntity entity, String sound, float volume, float pitch){ entity.getWorld().getMCWorld().playSoundAtEntity(entity.getMCEntity(), sound, volume, pitch); } - public void playSoundToNearExcept(ScriptPlayer player, String sound, float volume, float pitch){ + public void playSoundToNearExcept(IPlayer player, String sound, float volume, float pitch){ player.getWorld().getMCWorld().playSoundToNearExcept((EntityPlayerMP) player.getMCEntity(), sound, volume, pitch); } @@ -298,12 +298,12 @@ public class NpcAPI extends AbstractNpcAPI { MinecraftServer.getServer().setMOTD(motd); } - public ScriptParticle createParticle(String directory){ + public IParticle createParticle(String directory){ return new ScriptParticle(directory); } @Deprecated - public ScriptParticle createEntityParticle(String directory){ + public IParticle createEntityParticle(String directory){ return new ScriptParticle(directory); } diff --git a/src/main/java/noppes/npcs/scripted/ScriptBlock.java b/src/main/java/noppes/npcs/scripted/ScriptBlock.java index 1426c638e..d7ab06245 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptBlock.java +++ b/src/main/java/noppes/npcs/scripted/ScriptBlock.java @@ -15,7 +15,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import noppes.npcs.scripted.interfaces.*; -import noppes.npcs.scripted.wrapper.NpcAPI; import noppes.npcs.util.LRUHashMap; public class ScriptBlock implements IBlock { diff --git a/src/main/java/noppes/npcs/scripted/ScriptContainer.java b/src/main/java/noppes/npcs/scripted/ScriptContainer.java index ab4625e12..31a849364 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptContainer.java +++ b/src/main/java/noppes/npcs/scripted/ScriptContainer.java @@ -12,11 +12,9 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import noppes.npcs.NoppesUtilPlayer; import noppes.npcs.containers.ContainerCustomGui; -import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.interfaces.IContainer; +import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.item.IItemStack; -import noppes.npcs.scripted.item.ScriptItemStack; -import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptContainer implements IContainer { private IInventory inventory; @@ -96,11 +94,11 @@ public class ScriptContainer implements IContainer { container.detectAndSendChanges(); } - public void putStackInSlot(int slot, ScriptItemStack itemStack){ + public void putStackInSlot(int slot, IItemStack itemStack){ container.putStackInSlot(slot,itemStack.getMCItemStack()); } - public boolean isPlayerNotUsingContainer(ScriptPlayer player){ + public boolean isPlayerNotUsingContainer(IPlayer player){ return container.isPlayerNotUsingContainer((EntityPlayerMP) player.getMCEntity()); } } diff --git a/src/main/java/noppes/npcs/scripted/wrapper/ScriptDamageSource.java b/src/main/java/noppes/npcs/scripted/ScriptDamageSource.java similarity index 80% rename from src/main/java/noppes/npcs/scripted/wrapper/ScriptDamageSource.java rename to src/main/java/noppes/npcs/scripted/ScriptDamageSource.java index 15d89bb17..08bfe2583 100644 --- a/src/main/java/noppes/npcs/scripted/wrapper/ScriptDamageSource.java +++ b/src/main/java/noppes/npcs/scripted/ScriptDamageSource.java @@ -3,7 +3,7 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted.wrapper; +package noppes.npcs.scripted; import net.minecraft.util.DamageSource; import noppes.npcs.controllers.ScriptController; @@ -34,10 +34,10 @@ public class ScriptDamageSource implements IDamageSource { } public IEntity getTrueSource() { - return ScriptController.Instance.getScriptForEntity(this.source.getEntity()); + return NpcAPI.Instance().getIEntity(this.source.getEntity()); } public IEntity getImmediateSource() { - return ScriptController.Instance.getScriptForEntity(this.source.getSourceOfDamage()); + return NpcAPI.Instance().getIEntity(this.source.getSourceOfDamage()); } } diff --git a/src/main/java/noppes/npcs/scripted/ScriptFaction.java b/src/main/java/noppes/npcs/scripted/ScriptFaction.java index 972ecaf2b..8fdcd6fba 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptFaction.java +++ b/src/main/java/noppes/npcs/scripted/ScriptFaction.java @@ -1,8 +1,10 @@ package noppes.npcs.scripted; +import net.minecraft.entity.player.EntityPlayer; import noppes.npcs.controllers.Faction; -import noppes.npcs.scripted.entity.ScriptNpc; -import noppes.npcs.scripted.entity.ScriptPlayer; +import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.scripted.interfaces.entity.ICustomNpc; +import noppes.npcs.scripted.interfaces.entity.IPlayer; public class ScriptFaction { private Faction faction; @@ -33,19 +35,19 @@ public class ScriptFaction { return faction.color; } - public boolean isFriendlyToPlayer(ScriptPlayer player){ - return faction.isFriendlyToPlayer(player.player); + public boolean isFriendlyToPlayer(IPlayer player){ + return faction.isFriendlyToPlayer((EntityPlayer) player.getMCEntity()); } - public boolean isNeutralToPlayer(ScriptPlayer player){ - return faction.isNeutralToPlayer(player.player); + public boolean isNeutralToPlayer(IPlayer player){ + return faction.isNeutralToPlayer((EntityPlayer) player.getMCEntity()); } - public boolean isAggressiveToPlayer(ScriptPlayer player){ - return faction.isAggressiveToPlayer(player.player); + public boolean isAggressiveToPlayer(IPlayer player){ + return faction.isAggressiveToPlayer((EntityPlayer) player.getMCEntity()); } - public boolean isAggressiveToNpc(ScriptNpc npc){ - return faction.isAggressiveToNpc(npc.npc); + public boolean isAggressiveToNpc(ICustomNpc npc){ + return faction.isAggressiveToNpc((EntityNPCInterface) npc.getMCEntity()); } } diff --git a/src/main/java/noppes/npcs/scripted/ScriptParticle.java b/src/main/java/noppes/npcs/scripted/ScriptParticle.java index 04ba712ce..07a0b3209 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptParticle.java +++ b/src/main/java/noppes/npcs/scripted/ScriptParticle.java @@ -1,12 +1,9 @@ package noppes.npcs.scripted; import noppes.npcs.NoppesUtilServer; -import noppes.npcs.scripted.entity.ScriptEntity; import noppes.npcs.scripted.interfaces.IParticle; +import noppes.npcs.scripted.interfaces.entity.IEntity; -/** - * Created by luisc on 9/8/2021. - */ public class ScriptParticle implements IParticle { private String directory; @@ -52,7 +49,7 @@ public class ScriptParticle implements IParticle { this.directory = directory; } - public void spawnOnEntity(ScriptEntity entity){ + public void spawnOnEntity(IEntity entity){ int entityID = entity.getMCEntity().getEntityId(); NoppesUtilServer.spawnScriptedParticle(directory, HEXColor, HEXColor2, HEXColorRate, HEXColorStart, diff --git a/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java b/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java index a4ddb2408..9aecc2268 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java +++ b/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java @@ -6,7 +6,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; import noppes.npcs.scripted.interfaces.INbt; import noppes.npcs.scripted.interfaces.ITileEntity; -import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptTileEntity implements ITileEntity { protected T tileEntity; diff --git a/src/main/java/noppes/npcs/scripted/ScriptWorld.java b/src/main/java/noppes/npcs/scripted/ScriptWorld.java index f71528d65..eebbcb8f7 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptWorld.java +++ b/src/main/java/noppes/npcs/scripted/ScriptWorld.java @@ -24,14 +24,13 @@ import noppes.npcs.NoppesUtilServer; import noppes.npcs.blocks.tiles.TileBigSign; import noppes.npcs.controllers.ScriptController; import noppes.npcs.controllers.ServerCloneController; -import noppes.npcs.scripted.entity.ScriptEntity; -import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.interfaces.IBlock; +import noppes.npcs.scripted.interfaces.IParticle; +import noppes.npcs.scripted.interfaces.ITileEntity; import noppes.npcs.scripted.interfaces.entity.IEntity; +import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.IWorld; -import noppes.npcs.scripted.item.ScriptItemStack; -import noppes.npcs.scripted.wrapper.NpcAPI; public class ScriptWorld implements IWorld { private static Map tempData = new HashMap(); @@ -135,43 +134,43 @@ public class ScriptWorld implements IWorld { return world.getBlockLightValue(x,y,z); } - public void playSoundAtEntity(ScriptEntity entity, String sound, float volume, float pitch){ + public void playSoundAtEntity(IEntity entity, String sound, float volume, float pitch){ world.playSoundAtEntity(entity.getMCEntity(), sound, volume, pitch); } - public void playSoundToNearExcept(ScriptPlayer player, String sound, float volume, float pitch){ + public void playSoundToNearExcept(IPlayer player, String sound, float volume, float pitch){ world.playSoundToNearExcept((EntityPlayerMP) player.getMCEntity(), sound, volume, pitch); } public IEntity getEntityByID(int id){ - return ScriptController.Instance.getScriptForEntity(world.getEntityByID(id)); + return NpcAPI.Instance().getIEntity(world.getEntityByID(id)); } - public boolean spawnEntityInWorld(ScriptEntity entity){ + public boolean spawnEntityInWorld(IEntity entity){ return world.spawnEntityInWorld(entity.getMCEntity()); } - public ScriptPlayer getClosestPlayerToEntity(ScriptEntity entity, double range){ - return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(world.getClosestPlayerToEntity(entity.getMCEntity(), range)); + public IPlayer getClosestPlayerToEntity(IEntity entity, double range){ + return (IPlayer) NpcAPI.Instance().getIEntity(world.getClosestPlayerToEntity(entity.getMCEntity(), range)); } - public ScriptPlayer getClosestPlayer(double x, double y, double z, double range){ - return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(world.getClosestPlayer(x,y,z, range)); + public IPlayer getClosestPlayer(double x, double y, double z, double range){ + return (IPlayer) NpcAPI.Instance().getIEntity(world.getClosestPlayer(x,y,z, range)); } - public ScriptPlayer getClosestVulnerablePlayerToEntity(ScriptEntity entity, double range){ - return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(world.getClosestVulnerablePlayerToEntity(entity.getMCEntity(), range)); + public IPlayer getClosestVulnerablePlayerToEntity(IEntity entity, double range){ + return (IPlayer) NpcAPI.Instance().getIEntity(world.getClosestVulnerablePlayerToEntity(entity.getMCEntity(), range)); } - public ScriptPlayer getClosestVulnerablePlayer(double x, double y, double z, double range){ - return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(world.getClosestVulnerablePlayer(x,y,z, range)); + public IPlayer getClosestVulnerablePlayer(double x, double y, double z, double range){ + return (IPlayer) NpcAPI.Instance().getIEntity(world.getClosestVulnerablePlayer(x,y,z, range)); } - public int countEntities(ScriptEntity entity){ + public int countEntities(IEntity entity){ return world.countEntities(entity.getMCEntity().getClass()); } - public void setTileEntity(int x, int y, int z, ScriptTileEntity tileEntity){ + public void setTileEntity(int x, int y, int z, ITileEntity tileEntity){ world.setTileEntity(x,y,z,tileEntity.getMCTileEntity()); } @@ -230,12 +229,12 @@ public class ScriptWorld implements IWorld { * @param z World position z * @param item The block to be set */ - public void setBlock(int x, int y, int z, ScriptItemStack item){ + public void setBlock(int x, int y, int z, IItemStack item){ if(item == null){ removeBlock(x, y, z); return; } - Block block = Block.getBlockFromItem(item.item.getItem()); + Block block = Block.getBlockFromItem(item.getMCItemStack().getItem()); if(block == null || block == Blocks.air) return; world.setBlock(x, y, z, block); @@ -254,15 +253,15 @@ public class ScriptWorld implements IWorld { * @param name The name of the player to be returned * @return The Player with name. Null is returned when the player isnt found */ - public ScriptPlayer getPlayer(String name){ + public IPlayer getPlayer(String name){ EntityPlayer player = world.getPlayerEntityByName(name); if(player == null) return null; - return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(player); + return (IPlayer) NpcAPI.Instance().getIEntity(player); } - public ScriptPlayer getPlayerByUUID(String uuid){ - return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(world.func_152378_a(UUID.fromString(uuid))); + public IPlayer getPlayerByUUID(String uuid){ + return (IPlayer) NpcAPI.Instance().getIEntity(world.func_152378_a(UUID.fromString(uuid))); } /** @@ -333,8 +332,8 @@ public class ScriptWorld implements IWorld { * @return Returns ScriptParticle object */ @Deprecated - public ScriptParticle createEntityParticle(String directory){ - return new ScriptParticle(directory); + public IParticle createEntityParticle(String directory){ + return NpcAPI.Instance().createEntityParticle(directory); } /** @@ -440,11 +439,11 @@ public class ScriptWorld implements IWorld { world.newExplosion(null, x, y, z, range, fire, grief); } - public ScriptPlayer[] getAllServerPlayers(){ + public IPlayer[] getAllServerPlayers(){ List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; - ScriptPlayer[] arr = new ScriptPlayer[list.size()]; + IPlayer[] arr = new IPlayer[list.size()]; for(int i = 0; i < list.size(); i++){ - arr[i] = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(list.get(i)); + arr[i] = (IPlayer) NpcAPI.Instance().getIEntity(list.get(i)); } return arr; @@ -469,14 +468,14 @@ public class ScriptWorld implements IWorld { * @param name Name of the cloned entity * @return Returns the entity which was spawned */ - public ScriptEntity spawnClone(int x, int y, int z, int tab, String name){ + public IEntity spawnClone(int x, int y, int z, int tab, String name){ NBTTagCompound compound = ServerCloneController.Instance.getCloneData(null, name, tab); if(compound == null) return null; Entity entity = NoppesUtilServer.spawnClone(compound, x, y, z, world); if(entity == null) return null; - return ScriptController.Instance.getScriptForEntity(entity); + return NpcAPI.Instance().getIEntity(entity); } public ScriptScoreboard getScoreboard(){ diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java index f07bd9efe..7a62d246b 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java @@ -6,7 +6,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.interfaces.item.IItemStack; -import noppes.npcs.scripted.wrapper.NpcAPI; +import noppes.npcs.scripted.NpcAPI; public class ScriptDBCPlayer extends ScriptPlayer{ public T player; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index a143acf7e..8e390f50c 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -20,7 +20,6 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; import noppes.npcs.NoppesUtilServer; -import noppes.npcs.controllers.ScriptController; import noppes.npcs.controllers.ServerCloneController; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.*; @@ -28,8 +27,8 @@ import noppes.npcs.scripted.constants.EntityType; import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.INbt; import noppes.npcs.scripted.interfaces.IPos; -import noppes.npcs.scripted.item.ScriptItemStack; -import noppes.npcs.scripted.wrapper.NpcAPI; +import noppes.npcs.scripted.interfaces.item.IItemStack; +import noppes.npcs.scripted.NpcAPI; public class ScriptEntity implements IEntity { protected T entity; @@ -367,14 +366,14 @@ public class ScriptEntity implements IEntity { * @param range The search range for entities around this entity * @return Array of entities within range */ - public ScriptEntity[] getSurroundingEntities(int range){ + public IEntity[] getSurroundingEntities(int range){ List entities = entity.worldObj.getEntitiesWithinAABB(Entity.class, entity.boundingBox.expand(range, range, range)); - List list = new ArrayList(); + List list = new ArrayList(); for(Entity living : entities){ if(living != entity) - list.add(ScriptController.Instance.getScriptForEntity(living)); + list.add(NpcAPI.Instance().getIEntity(living)); } - return list.toArray(new ScriptEntity[list.size()]); + return list.toArray(new IEntity[list.size()]); } /** @@ -382,7 +381,7 @@ public class ScriptEntity implements IEntity { * @param type The EntityType you want to find * @return Array of entities within range */ - public ScriptEntity[] getSurroundingEntities(int range, int type){ + public IEntity[] getSurroundingEntities(int range, int type){ Class cls = Entity.class; if(type == EntityType.LIVING) cls = EntityLivingBase.class; @@ -396,12 +395,12 @@ public class ScriptEntity implements IEntity { cls = EntityNPCInterface.class; List entities = entity.worldObj.getEntitiesWithinAABB(cls, entity.boundingBox.expand(range, range, range)); - List list = new ArrayList(); + List list = new ArrayList(); for(Entity living : entities){ if(living != entity) - list.add(ScriptController.Instance.getScriptForEntity(living)); + list.add(NpcAPI.Instance().getIEntity(living)); } - return list.toArray(new ScriptEntity[list.size()]); + return list.toArray(new IEntity[list.size()]); } @@ -581,23 +580,23 @@ public class ScriptEntity implements IEntity { /** * @param item Item to be dropped */ - public void dropItem(ScriptItemStack item){ - entity.entityDropItem(item.item, 0); + public void dropItem(IItemStack item){ + entity.entityDropItem(item.getMCItemStack(), 0); } /** * @return Return the rider */ - public ScriptEntity getRider(){ - return ScriptController.Instance.getScriptForEntity(entity.riddenByEntity); + public IEntity getRider(){ + return NpcAPI.Instance().getIEntity(entity.riddenByEntity); } /** * @param entity The entity to ride this entity */ - public void setRider(ScriptEntity entity){ + public void setRider(IEntity entity){ if(entity != null){ - entity.entity.mountEntity(this.entity);; + entity.getMCEntity().mountEntity(this.entity);; } else if(this.entity.riddenByEntity != null) this.entity.riddenByEntity.mountEntity(null); @@ -606,18 +605,18 @@ public class ScriptEntity implements IEntity { /** * @return Return the entity, this entity is riding */ - public ScriptEntity getMount(){ - return ScriptController.Instance.getScriptForEntity(entity.ridingEntity); + public IEntity getMount(){ + return NpcAPI.Instance().getIEntity(entity.ridingEntity); } /** * @param entity The entity this entity will mount */ - public void setMount(ScriptEntity entity){ + public void setMount(IEntity entity){ if(entity == null) this.entity.mountEntity(null); else - this.entity.mountEntity(entity.entity); + this.entity.mountEntity(entity.getMCEntity()); } /** diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptLiving.java b/src/main/java/noppes/npcs/scripted/entity/ScriptLiving.java index d175e78fd..5d80811e2 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptLiving.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptLiving.java @@ -1,8 +1,10 @@ package noppes.npcs.scripted.entity; import net.minecraft.entity.EntityLiving; -import noppes.npcs.controllers.ScriptController; +import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.entity.IEntityLiving; +import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; public class ScriptLiving extends ScriptLivingBase implements IEntityLiving { @@ -18,17 +20,17 @@ public class ScriptLiving extends ScriptLivingBase im } @Override - public void setAttackTarget(ScriptLivingBase living){ + public void setAttackTarget(IEntityLivingBase living){ if(living == null) entity.setAttackTarget(null); else - entity.setAttackTarget(living.entity); + entity.setAttackTarget(living.getMCEntity()); super.setAttackTarget(living); } @Override - public ScriptLivingBase getAttackTarget(){ - ScriptLivingBase base = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(entity.getAttackTarget()); + public IEntityLivingBase getAttackTarget(){ + IEntityLivingBase base = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity.getAttackTarget()); return (base != null)? base: super.getAttackTarget(); } @@ -58,7 +60,7 @@ public class ScriptLiving extends ScriptLivingBase im } @Override - public boolean canSeeEntity(ScriptEntity entity){ - return this.entity.getEntitySenses().canSee(entity.entity); + public boolean canSeeEntity(IEntity entity){ + return this.entity.getEntitySenses().canSee(entity.getMCEntity()); } } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java index 5b8ea05c0..e10fd4187 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java @@ -6,13 +6,12 @@ import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; import net.minecraft.util.EntityDamageSource; -import noppes.npcs.controllers.ScriptController; +import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.item.IItemStack; -import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.constants.EntityType; import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; -import noppes.npcs.scripted.wrapper.NpcAPI; -import noppes.npcs.scripted.wrapper.ScriptDamageSource; +import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.ScriptDamageSource; public class ScriptLivingBase extends ScriptEntity implements IEntityLivingBase { protected T entity; @@ -40,7 +39,7 @@ public class ScriptLivingBase extends ScriptEntity extends ScriptEntity extends ScriptEntity extends ScriptEntity extends ScriptEntity extends ScriptLiving imp * @param item The item you want to shoot * @param accuracy Accuracy of the shot (0-100) */ - public void shootItem(ScriptLivingBase target, ScriptItemStack item, int accuracy){ + public void shootItem(IEntityLivingBase target, IItemStack item, int accuracy){ if(item == null) return; if(accuracy < 0) accuracy = 0; else if(accuracy > 100) accuracy = 100; - npc.shoot(target.entity, accuracy, item.item, false); + npc.shoot(target.getMCEntity(), accuracy, item.getMCItemStack(), false); } /** @@ -280,10 +282,10 @@ public class ScriptNpc extends ScriptLiving imp /** * @param message The message the npc will say */ - public void say(ScriptPlayer player, String message){ + public void say(IPlayer player, String message){ if(player == null || message == null || message.isEmpty()) return; - npc.say(player.player, new Line(message)); + npc.say((EntityPlayer) player.getMCEntity(), new Line(message)); } /** @@ -368,11 +370,11 @@ public class ScriptNpc extends ScriptLiving imp /** * @param item Item to be held in the right hand */ - public void setRightItem(ScriptItemStack item){ + public void setRightItem(IItemStack item){ if(item == null) npc.inventory.setWeapon(null); else - npc.inventory.setWeapon(item.item); + npc.inventory.setWeapon(item.getMCItemStack()); npc.script.clientNeedsUpdate = true; } @@ -386,11 +388,11 @@ public class ScriptNpc extends ScriptLiving imp /** * @param item Item to be held in the left hand */ - public void setLeftItem(ScriptItemStack item){ + public void setLeftItem(IItemStack item){ if(item == null) npc.inventory.setOffHand(null); else - npc.inventory.setOffHand(item.item); + npc.inventory.setOffHand(item.getMCItemStack()); npc.script.clientNeedsUpdate = true; } @@ -404,11 +406,11 @@ public class ScriptNpc extends ScriptLiving imp /** * @param item Item to be used as projectile */ - public void setProjectileItem(ScriptItemStack item){ + public void setProjectileItem(IItemStack item){ if(item == null) npc.inventory.setProjectile(null); else - npc.inventory.setProjectile(item.item); + npc.inventory.setProjectile(item.getMCItemStack()); npc.script.aiNeedsUpdate = true; } @@ -491,11 +493,11 @@ public class ScriptNpc extends ScriptLiving imp * @param item Item to be set as armor */ @Override - public void setArmor(int slot, ScriptItemStack item){ + public void setArmor(int slot, IItemStack item){ if(item == null) npc.inventory.armor.put(slot, null); else - npc.inventory.armor.put(slot, item.item); + npc.inventory.armor.put(slot, item.getMCItemStack()); npc.script.clientNeedsUpdate = true; } @@ -514,8 +516,8 @@ public class ScriptNpc extends ScriptLiving imp * @param slot The slot from the NPC's drop list to change * @param item The item the drop list slot will be changed to */ - public void setLootItem(int slot, ScriptItemStack item) { - npc.inventory.setInventorySlotContents(slot+7, item.item); + public void setLootItem(int slot, IItemStack item) { + npc.inventory.setInventorySlotContents(slot+7, item.getMCItemStack()); } /** @@ -694,8 +696,8 @@ public class ScriptNpc extends ScriptLiving imp return npc.display.visible; } - public void setVisibleTo(ScriptPlayer player, boolean visible) { - UUID uuid = player.player.getPersistentID(); + public void setVisibleTo(IPlayer player, boolean visible) { + UUID uuid = player.getMCEntity().getPersistentID(); ArrayList uuidList = npc.display.invisibleToList; if(uuidList != null) { if (!uuidList.contains(uuid)) { @@ -708,8 +710,8 @@ public class ScriptNpc extends ScriptLiving imp npc.script.clientNeedsUpdate = true; } - public boolean isVisibleTo(ScriptPlayer player) { - return !npc.scriptInvisibleToPlayer(player.player); + public boolean isVisibleTo(IPlayer player) { + return !npc.scriptInvisibleToPlayer((EntityPlayer) player.getMCEntity()); } /** @@ -849,8 +851,8 @@ public class ScriptNpc extends ScriptLiving imp npc.stats.canDespawn = canDespawn; } - public void giveItem(ScriptPlayer player, ScriptItemStack item){ - npc.givePlayerItem(player.player, item.item); + public void giveItem(IPlayer player, IItemStack item){ + npc.givePlayerItem((EntityPlayer) player.getMCEntity(), item.getMCItemStack()); } public void executeCommand(String command){ diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index 8d3ed0a61..e1bdf8721 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -20,15 +20,15 @@ import noppes.npcs.entity.EntityDialogNpc; import noppes.npcs.scripted.*; import noppes.npcs.scripted.constants.EntityType; import noppes.npcs.scripted.gui.ScriptGui; +import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.handler.data.IQuest; import noppes.npcs.scripted.interfaces.*; import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.gui.ICustomGui; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay; -import noppes.npcs.scripted.item.ScriptItemStack; import noppes.npcs.scripted.overlay.ScriptOverlay; -import noppes.npcs.scripted.wrapper.NpcAPI; +import noppes.npcs.scripted.NpcAPI; import noppes.npcs.util.ValueUtil; import java.util.ArrayList; @@ -229,10 +229,10 @@ public class ScriptPlayer extends ScriptLivingBase * @param item The item to be checked * @return How many of this item the player has */ - public int inventoryItemCount(ScriptItemStack item){ + public int inventoryItemCount(IItemStack item){ int i = 0; for(ItemStack is : player.inventory.mainInventory){ - if (is != null && is.isItemEqual(item.item)) + if (is != null && is.isItemEqual(item.getMCItemStack())) i += is.stackSize; } return i; @@ -257,7 +257,7 @@ public class ScriptPlayer extends ScriptLivingBase * @param amount How many will be removed * @return Returns true if the items were removed succesfully. Returns false incase a bigger amount than what the player has was given */ - public boolean removeItem(ScriptItemStack item, int amount){ + public boolean removeItem(IItemStack item, int amount){ int count = inventoryItemCount(item); if(amount > count) return false; @@ -266,7 +266,7 @@ public class ScriptPlayer extends ScriptLivingBase else{ for(int i = 0; i < player.inventory.mainInventory.length; i++){ ItemStack is = player.inventory.mainInventory[i]; - if (is != null && is.isItemEqual(item.item)){ + if (is != null && is.isItemEqual(item.getMCItemStack())){ if(amount > is.stackSize){ player.inventory.mainInventory[i] = null; amount -= is.stackSize; @@ -293,7 +293,7 @@ public class ScriptPlayer extends ScriptLivingBase Item item = (Item)Item.itemRegistry.getObject(id); if(item == null) return false; - return removeItem(new ScriptItemStack(new ItemStack(item, 1, damage)), amount); + return removeItem(NpcAPI.Instance().getIItemStack(new ItemStack(item, 1, damage)), amount); } /** @@ -302,7 +302,7 @@ public class ScriptPlayer extends ScriptLivingBase * @param amount The amount of the item to be added * @return Returns whether or not it gave the item succesfully */ - public boolean giveItem(ScriptItemStack item, int amount){ + public boolean giveItem(IItemStack item, int amount){ if(item != null && item.getMCItemStack() != null) { item.setStackSize(amount); boolean bool = this.player.inventory.addItemStackToInventory(item.getMCItemStack()); @@ -347,10 +347,10 @@ public class ScriptPlayer extends ScriptLivingBase /** * @param item The item to be removed from the players inventory */ - public void removeAllItems(ScriptItemStack item){ + public void removeAllItems(IItemStack item){ for(int i = 0; i < player.inventory.mainInventory.length; i++){ ItemStack is = player.inventory.mainInventory[i]; - if (is != null && is.isItemEqual(item.item)) + if (is != null && is.isItemEqual(item.getMCItemStack())) player.inventory.mainInventory[i] = null; } } @@ -383,15 +383,15 @@ public class ScriptPlayer extends ScriptLivingBase player.mountEntity(ridingEntity); } - public ScriptEntity dropOneItem(boolean dropStack){ - return new ScriptEntity(player.dropOneItem(dropStack)); + public IEntity dropOneItem(boolean dropStack){ + return NpcAPI.Instance().getIEntity(player.dropOneItem(dropStack)); } public boolean canHarvestBlock(ScriptBlock block){ return player.canHarvestBlock(block.getMCBlock()); } - public boolean interactWith(ScriptEntity entity){ + public boolean interactWith(IEntity entity){ return player.interactWith(entity.getMCEntity()); } diff --git a/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java b/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java index 537a889c1..ec0b120f1 100644 --- a/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/CustomNPCsEvent.java @@ -6,7 +6,7 @@ package noppes.npcs.scripted.event; import cpw.mods.fml.common.eventhandler.Event; -import noppes.npcs.scripted.AbstractNpcAPI; +import noppes.npcs.scripted.interfaces.AbstractNpcAPI; public class CustomNPCsEvent extends Event{ public final AbstractNpcAPI API = AbstractNpcAPI.Instance(); diff --git a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java index 03de543d6..1fe400811 100644 --- a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java @@ -18,7 +18,7 @@ import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.item.IItemStack; -import noppes.npcs.scripted.wrapper.NpcAPI; +import noppes.npcs.scripted.NpcAPI; public class NpcEvent extends CustomNPCsEvent { public final ICustomNpc npc; @@ -41,7 +41,7 @@ public class NpcEvent extends CustomNPCsEvent { public CollideEvent(ICustomNpc npc, Entity entity) { super(npc); - this.entity = ScriptController.Instance.getScriptForEntity(entity); + this.entity = NpcAPI.Instance().getIEntity(entity); } } @@ -54,7 +54,7 @@ public class NpcEvent extends CustomNPCsEvent { public DamagedEvent(ICustomNpc npc, Entity source, float damage, DamageSource damagesource) { super(npc); - this.source = ScriptController.Instance.getScriptForEntity(source); + this.source = NpcAPI.Instance().getIEntity(source); this.damage = damage; this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource); } @@ -71,7 +71,7 @@ public class NpcEvent extends CustomNPCsEvent { public RangedLaunchedEvent(ICustomNpc npc, float damage, EntityLivingBase target) { super(npc); - this.target = (IEntityLivingBase)ScriptController.Instance.getScriptForEntity(target); + this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target); this.damage = damage; } } @@ -83,7 +83,7 @@ public class NpcEvent extends CustomNPCsEvent { public MeleeAttackEvent(ICustomNpc npc, float damage, EntityLivingBase target) { super(npc); - this.target = (IEntityLivingBase)ScriptController.Instance.getScriptForEntity(target); + this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target); this.damage = damage; } } @@ -93,7 +93,7 @@ public class NpcEvent extends CustomNPCsEvent { public KilledEntityEvent(ICustomNpc npc, EntityLivingBase entity) { super(npc); - this.entity = (IEntityLivingBase)ScriptController.Instance.getScriptForEntity(entity); + this.entity = (IEntityLivingBase)NpcAPI.Instance().getIEntity(entity); } } @@ -108,7 +108,7 @@ public class NpcEvent extends CustomNPCsEvent { super(npc); this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource); this.type = damagesource.damageType; - this.source = ScriptController.Instance.getScriptForEntity(entity); + this.source = NpcAPI.Instance().getIEntity(entity); } public String getType(){ @@ -122,7 +122,7 @@ public class NpcEvent extends CustomNPCsEvent { public InteractEvent(ICustomNpc npc, EntityPlayer player) { super(npc); - this.player = (IPlayer)ScriptController.Instance.getScriptForEntity(player); + this.player = (IPlayer)NpcAPI.Instance().getIEntity(player); } } @@ -134,7 +134,7 @@ public class NpcEvent extends CustomNPCsEvent { public DialogEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) { super(npc); - this.player = (IPlayer)ScriptController.Instance.getScriptForEntity(player); + this.player = (IPlayer)NpcAPI.Instance().getIEntity(player); this.id = id; this.optionId = optionId; this.dialog = dialog; @@ -149,7 +149,7 @@ public class NpcEvent extends CustomNPCsEvent { public DialogClosedEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) { super(npc); - this.player = (IPlayer)ScriptController.Instance.getScriptForEntity(player); + this.player = (IPlayer)NpcAPI.Instance().getIEntity(player); this.id = id; this.optionId = optionId; this.dialog = dialog; @@ -162,7 +162,7 @@ public class NpcEvent extends CustomNPCsEvent { public TargetLostEvent(ICustomNpc npc, EntityLivingBase entity) { super(npc); - this.entity = (IEntityLivingBase) ScriptController.Instance.getScriptForEntity(entity); + this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity); } } @@ -172,7 +172,7 @@ public class NpcEvent extends CustomNPCsEvent { public TargetEvent(ICustomNpc npc, EntityLivingBase entity) { super(npc); - this.entity = (IEntityLivingBase) ScriptController.Instance.getScriptForEntity(entity); + this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity); } } diff --git a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java index 390f8279a..f9e5eab78 100644 --- a/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/PlayerEvent.java @@ -12,15 +12,12 @@ import net.minecraft.entity.item.EntityXPOrb; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.world.World; -import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.entity.ScriptLivingBase; import noppes.npcs.scripted.interfaces.*; import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.item.IItemStack; -import noppes.npcs.scripted.item.ScriptItemStack; -import noppes.npcs.scripted.wrapper.NpcAPI; +import noppes.npcs.scripted.NpcAPI; public class PlayerEvent extends CustomNPCsEvent { public final IPlayer player; @@ -138,7 +135,7 @@ public class PlayerEvent extends CustomNPCsEvent { public DamagedEvent(IPlayer player, Entity source, float damage, DamageSource damagesource) { super(player); - this.source = ScriptController.Instance.getScriptForEntity(source); + this.source = NpcAPI.Instance().getIEntity(source); this.damage = damage; this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource); } @@ -185,7 +182,7 @@ public class PlayerEvent extends CustomNPCsEvent { public KilledEntityEvent(IPlayer player, EntityLivingBase entity) { super(player); - this.entity = new ScriptLivingBase<>(entity);//NpcAPI.Instance().getIEntity(entity); + this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity); } } @@ -199,7 +196,7 @@ public class PlayerEvent extends CustomNPCsEvent { super(player); this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource); this.type = damagesource.getDamageType(); - this.source = ScriptController.Instance.getScriptForEntity(entity); + this.source = NpcAPI.Instance().getIEntity(entity); } } @@ -223,7 +220,7 @@ public class PlayerEvent extends CustomNPCsEvent { public DamagedEntityEvent(IPlayer player, Entity target, float damage, DamageSource damagesource) { super(player); - this.target = ScriptController.Instance.getScriptForEntity(target); + this.target = NpcAPI.Instance().getIEntity(target); this.damage = damage; this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource); } @@ -378,7 +375,7 @@ public class PlayerEvent extends CustomNPCsEvent { public UseHoe(IPlayer player, ItemStack item, int x, int y, int z) { super(player); - this.hoe = new ScriptItemStack(item); + this.hoe = NpcAPI.Instance().getIItemStack(item); this.x = x; this.y = y; this.z = z; @@ -422,8 +419,8 @@ public class PlayerEvent extends CustomNPCsEvent { public FillBucket(IPlayer player, ItemStack current, ItemStack result) { super(player); - this.current = new ScriptItemStack(current); - this.result = new ScriptItemStack(result); + this.current = NpcAPI.Instance().getIItemStack(current); + this.result = NpcAPI.Instance().getIItemStack(result); } } diff --git a/src/main/java/noppes/npcs/scripted/event/ScriptEventAttack.java b/src/main/java/noppes/npcs/scripted/event/ScriptEventAttack.java index 5b37517a4..0b8403c3f 100644 --- a/src/main/java/noppes/npcs/scripted/event/ScriptEventAttack.java +++ b/src/main/java/noppes/npcs/scripted/event/ScriptEventAttack.java @@ -1,26 +1,26 @@ package noppes.npcs.scripted.event; import net.minecraft.entity.EntityLivingBase; -import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.entity.ScriptLivingBase; +import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; public class ScriptEventAttack extends ScriptEvent{ private float damage; - private ScriptLivingBase target; + private IEntityLivingBase target; private boolean isRanged; public ScriptEventAttack(float damage, EntityLivingBase target, boolean isRanged){ this.damage = damage; this.isRanged = isRanged; - this.target = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(target); + this.target = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target); } /** * @return The source of the damage * @deprecated */ - public ScriptLivingBase getTarget(){ + public IEntityLivingBase getTarget(){ return target; } diff --git a/src/main/java/noppes/npcs/scripted/event/ScriptEventDamaged.java b/src/main/java/noppes/npcs/scripted/event/ScriptEventDamaged.java index 8a21666e5..f4511a400 100644 --- a/src/main/java/noppes/npcs/scripted/event/ScriptEventDamaged.java +++ b/src/main/java/noppes/npcs/scripted/event/ScriptEventDamaged.java @@ -2,26 +2,26 @@ package noppes.npcs.scripted.event; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.DamageSource; -import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.entity.ScriptLivingBase; +import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; public class ScriptEventDamaged extends ScriptEvent{ private float damage; private boolean clear = false; - private ScriptLivingBase source; + private IEntityLivingBase source; private DamageSource damagesource; public ScriptEventDamaged(float damage, EntityLivingBase attackingEntity, DamageSource damagesource){ this.damage = damage; this.damagesource = damagesource; - this.source = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(attackingEntity); + this.source = (IEntityLivingBase) NpcAPI.Instance().getIEntity(attackingEntity); } /** * @return The source of the damage */ - public ScriptLivingBase getSource(){ + public IEntityLivingBase getSource(){ return source; } diff --git a/src/main/java/noppes/npcs/scripted/event/ScriptEventDialog.java b/src/main/java/noppes/npcs/scripted/event/ScriptEventDialog.java index 06189f348..436cb7027 100644 --- a/src/main/java/noppes/npcs/scripted/event/ScriptEventDialog.java +++ b/src/main/java/noppes/npcs/scripted/event/ScriptEventDialog.java @@ -3,6 +3,7 @@ package noppes.npcs.scripted.event; import net.minecraft.entity.player.EntityPlayer; import noppes.npcs.controllers.Dialog; import noppes.npcs.controllers.ScriptController; +import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.entity.IPlayer; public class ScriptEventDialog extends ScriptEvent{ @@ -12,7 +13,7 @@ public class ScriptEventDialog extends ScriptEvent{ public Dialog dialogObj; public ScriptEventDialog(EntityPlayer player, int dialog, int option, Dialog dialogObj){ - this.player = (IPlayer) ScriptController.Instance.getScriptForEntity(player); + this.player = (IPlayer) NpcAPI.Instance().getIEntity(player); this.dialog = dialog; this.option = option; this.dialogObj = dialogObj; diff --git a/src/main/java/noppes/npcs/scripted/event/ScriptEventKilled.java b/src/main/java/noppes/npcs/scripted/event/ScriptEventKilled.java index 606002a34..8362598a7 100644 --- a/src/main/java/noppes/npcs/scripted/event/ScriptEventKilled.java +++ b/src/main/java/noppes/npcs/scripted/event/ScriptEventKilled.java @@ -2,26 +2,28 @@ package noppes.npcs.scripted.event; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.DamageSource; -import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.entity.ScriptLivingBase; +import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.interfaces.IDamageSource; +import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; public class ScriptEventKilled extends ScriptEvent{ - - private ScriptLivingBase source; + private IEntityLivingBase source; private DamageSource damagesource; public ScriptEventKilled(EntityLivingBase target, DamageSource damagesource){ this.damagesource = damagesource; - this.source = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(target); + this.source = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target); } /** * @return The source of the damage */ - public ScriptLivingBase getSource(){ + public IEntityLivingBase getSource(){ return source; } + public IDamageSource getDamageSource() { return NpcAPI.Instance().getIDamageSource(damagesource); } + /** * @return Returns the damage type */ diff --git a/src/main/java/noppes/npcs/scripted/event/ScriptEventTarget.java b/src/main/java/noppes/npcs/scripted/event/ScriptEventTarget.java index 1bb9832c2..10d2effc1 100644 --- a/src/main/java/noppes/npcs/scripted/event/ScriptEventTarget.java +++ b/src/main/java/noppes/npcs/scripted/event/ScriptEventTarget.java @@ -1,27 +1,26 @@ package noppes.npcs.scripted.event; import net.minecraft.entity.EntityLivingBase; -import noppes.npcs.controllers.ScriptController; -import noppes.npcs.scripted.entity.ScriptLivingBase; +import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; public class ScriptEventTarget extends ScriptEvent { - private ScriptLivingBase target; + private IEntityLivingBase target; public ScriptEventTarget(EntityLivingBase target){ if(target != null) - this.target = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(target); + this.target = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target); } - /** * @return The source of the damage */ - public ScriptLivingBase getTarget(){ + public IEntityLivingBase getTarget(){ return target; } - public void setTarget(ScriptLivingBase target){ + public void setTarget(IEntityLivingBase target){ this.target = target; } } diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGui.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGui.java index 893ef2dc6..ea9ace5f2 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGui.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGui.java @@ -14,7 +14,6 @@ import net.minecraft.nbt.NBTTagList; import noppes.npcs.controllers.ScriptController; import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.scripted.interfaces.gui.*; -import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.controllers.CustomGuiController; import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.item.IItemStack; @@ -215,7 +214,7 @@ public class ScriptGui implements ICustomGui { } public void update(IPlayer player) { - CustomGuiController.updateGui((ScriptPlayer)player, this); + CustomGuiController.updateGui(player, this); } public boolean getShowPlayerInv() { diff --git a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiItemSlot.java b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiItemSlot.java index 2697c47da..ca9af41aa 100644 --- a/src/main/java/noppes/npcs/scripted/gui/ScriptGuiItemSlot.java +++ b/src/main/java/noppes/npcs/scripted/gui/ScriptGuiItemSlot.java @@ -5,7 +5,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.scripted.interfaces.gui.IItemSlot; import noppes.npcs.scripted.interfaces.item.IItemStack; -import noppes.npcs.scripted.wrapper.NpcAPI; +import noppes.npcs.scripted.NpcAPI; public class ScriptGuiItemSlot extends ScriptGuiComponent implements IItemSlot { IItemStack stack; diff --git a/src/main/java/noppes/npcs/scripted/AbstractNpcAPI.java b/src/main/java/noppes/npcs/scripted/interfaces/AbstractNpcAPI.java similarity index 86% rename from src/main/java/noppes/npcs/scripted/AbstractNpcAPI.java rename to src/main/java/noppes/npcs/scripted/interfaces/AbstractNpcAPI.java index 0a9a2847d..ebf02a7f0 100644 --- a/src/main/java/noppes/npcs/scripted/AbstractNpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/AbstractNpcAPI.java @@ -3,7 +3,7 @@ // (powered by FernFlower decompiler) // -package noppes.npcs.scripted; +package noppes.npcs.scripted.interfaces; import java.io.File; @@ -18,10 +18,9 @@ import net.minecraft.util.DamageSource; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.WorldServer; -import noppes.npcs.scripted.entity.ScriptPlayer; -import noppes.npcs.scripted.interfaces.*; import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import noppes.npcs.scripted.interfaces.entity.IEntity; +import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.item.IItemStack; public abstract class AbstractNpcAPI { @@ -71,7 +70,7 @@ public abstract class AbstractNpcAPI { return null; } else { try { - Class c = Class.forName("noppes.npcs.scripted.wrapper.NpcAPI"); + Class c = Class.forName("noppes.npcs.scripted.NpcAPI"); instance = (AbstractNpcAPI) c.getMethod("Instance").invoke((Object) null); } catch (Exception var1) { var1.printStackTrace(); @@ -87,13 +86,13 @@ public abstract class AbstractNpcAPI { public abstract INbt getINbt(NBTTagCompound entityData); - public abstract ScriptPlayer[] getAllServerPlayers(); + public abstract IPlayer[] getAllServerPlayers(); public abstract IItemStack createItem(String id, int damage, int size); - public abstract ScriptParticle createParticle(String directory); + public abstract IParticle createParticle(String directory); - public abstract ScriptParticle createEntityParticle(String directory); + public abstract IParticle createEntityParticle(String directory); public abstract int getServerTime(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java b/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java index 15a474c8d..47f6d5358 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java @@ -7,9 +7,8 @@ package noppes.npcs.scripted.interfaces; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; +import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.item.IItemStack; -import noppes.npcs.scripted.item.ScriptItemStack; -import noppes.npcs.scripted.entity.ScriptPlayer; public interface IContainer { int getSize(); @@ -30,7 +29,7 @@ public interface IContainer { void detectAndSendChanges(); - void putStackInSlot(int slot, ScriptItemStack itemStack); + void putStackInSlot(int slot, IItemStack itemStack); - boolean isPlayerNotUsingContainer(ScriptPlayer player); + boolean isPlayerNotUsingContainer(IPlayer player); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java b/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java index e3b3c4cd2..1929e048d 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java @@ -2,11 +2,11 @@ package noppes.npcs.scripted.interfaces; import noppes.npcs.NoppesUtilServer; import noppes.npcs.scripted.ScriptWorld; -import noppes.npcs.scripted.entity.ScriptEntity; +import noppes.npcs.scripted.interfaces.entity.IEntity; public interface IParticle { - void spawnOnEntity(ScriptEntity entity); + void spawnOnEntity(IEntity entity); void spawnInWorld(ScriptWorld world); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java index cf18f8088..828ff5dd3 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java @@ -3,11 +3,9 @@ package noppes.npcs.scripted.interfaces; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; import noppes.npcs.scripted.*; -import noppes.npcs.scripted.entity.ScriptEntity; -import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.interfaces.entity.IEntity; +import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.item.IItemStack; -import noppes.npcs.scripted.item.ScriptItemStack; public interface IWorld { /** @@ -58,25 +56,25 @@ public interface IWorld { int getBlockLightValue(int x, int y, int z); - void playSoundAtEntity(ScriptEntity entity, String sound, float volume, float pitch); + void playSoundAtEntity(IEntity entity, String sound, float volume, float pitch); - void playSoundToNearExcept(ScriptPlayer player, String sound, float volume, float pitch); + void playSoundToNearExcept(IPlayer player, String sound, float volume, float pitch); IEntity getEntityByID(int id); - boolean spawnEntityInWorld(ScriptEntity entity); + boolean spawnEntityInWorld(IEntity entity); - ScriptPlayer getClosestPlayerToEntity(ScriptEntity entity, double range); + IPlayer getClosestPlayerToEntity(IEntity entity, double range); - ScriptPlayer getClosestPlayer(double x, double y, double z, double range); + IPlayer getClosestPlayer(double x, double y, double z, double range); - ScriptPlayer getClosestVulnerablePlayerToEntity(ScriptEntity entity, double range); + IPlayer getClosestVulnerablePlayerToEntity(IEntity entity, double range); - ScriptPlayer getClosestVulnerablePlayer(double x, double y, double z, double range); + IPlayer getClosestVulnerablePlayer(double x, double y, double z, double range); - int countEntities(ScriptEntity entity); + int countEntities(IEntity entity); - void setTileEntity(int x, int y, int z, ScriptTileEntity tileEntity); + void setTileEntity(int x, int y, int z, ITileEntity tileEntity); void removeTileEntity(int x, int y, int z); @@ -105,7 +103,7 @@ public interface IWorld { * @param z World position z * @param item The block to be set */ - void setBlock(int x, int y, int z, ScriptItemStack item); + void setBlock(int x, int y, int z, IItemStack item); /** * @param x World position x @@ -118,9 +116,9 @@ public interface IWorld { * @param name The name of the player to be returned * @return The Player with name. Null is returned when the player isnt found */ - ScriptPlayer getPlayer(String name); + IPlayer getPlayer(String name); - ScriptPlayer getPlayerByUUID(String uuid); + IPlayer getPlayerByUUID(String uuid); /** * @param time The world time to be set @@ -173,9 +171,9 @@ public interface IWorld { /** * @param directory The particle's texture directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/tail.png" - * @return Returns ScriptEntityParticle object + * @return Returns IEntityParticle object */ - ScriptParticle createEntityParticle(String directory); + IParticle createEntityParticle(String directory); /** * @param key Get temp data for this key @@ -245,7 +243,7 @@ public interface IWorld { */ void explode(double x, double y, double z, float range, boolean fire, boolean grief); - ScriptPlayer[] getAllServerPlayers(); + IPlayer[] getAllServerPlayers(); /** * @since 1.7.10c @@ -264,7 +262,7 @@ public interface IWorld { * @param name Name of the cloned entity * @return Returns the entity which was spawned */ - ScriptEntity spawnClone(int x, int y, int z, int tab, String name); + IEntity spawnClone(int x, int y, int z, int tab, String name); ScriptScoreboard getScoreboard(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java index e46ccd53f..8b9efff78 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java @@ -9,9 +9,6 @@ import net.minecraft.entity.EntityCreature; import noppes.npcs.scripted.ScriptFaction; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.ITimers; -import noppes.npcs.scripted.item.ScriptItemStack; -import noppes.npcs.scripted.entity.ScriptLivingBase; -import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.roles.*; public interface ICustomNpc extends IEntityLiving { @@ -167,7 +164,7 @@ public interface ICustomNpc extends IEntityLiving { * @param item The item you want to shoot * @param accuracy Accuracy of the shot (0-100) */ - void shootItem(ScriptLivingBase target, ScriptItemStack item, int accuracy); + void shootItem(IEntityLivingBase target, IItemStack item, int accuracy); /** * @param message The message the npc will say @@ -177,7 +174,7 @@ public interface ICustomNpc extends IEntityLiving { /** * @param message The message the npc will say */ - void say(ScriptPlayer player, String message); + void say(IPlayer player, String message); /** * Kill the npc, doesnt't despawn it @@ -211,7 +208,7 @@ public interface ICustomNpc extends IEntityLiving { /** * @param item Item to be held in the right hand */ - void setRightItem(ScriptItemStack item); + void setRightItem(IItemStack item); /** * @return The item held in the left hand @@ -221,7 +218,7 @@ public interface ICustomNpc extends IEntityLiving { /** * @param item Item to be held in the left hand */ - void setLeftItem(ScriptItemStack item); + void setLeftItem(IItemStack item); /** * @return Returns the projectile the npc uses @@ -231,7 +228,7 @@ public interface ICustomNpc extends IEntityLiving { /** * @param item Item to be used as projectile */ - void setProjectileItem(ScriptItemStack item); + void setProjectileItem(IItemStack item); /** * @@ -288,7 +285,7 @@ public interface ICustomNpc extends IEntityLiving { * @param slot The armor slot to set. 0:head, 1:body, 2:legs, 3:boots * @param item Item to be set as armor */ - void setArmor(int slot, ScriptItemStack item); + void setArmor(int slot, IItemStack item); /** * @@ -302,7 +299,7 @@ public interface ICustomNpc extends IEntityLiving { * @param slot The slot from the NPC's drop list to change * @param item The item the drop list slot will be changed to */ - void setLootItem(int slot, ScriptItemStack item); + void setLootItem(int slot, IItemStack item); /** * @@ -488,7 +485,7 @@ public interface ICustomNpc extends IEntityLiving { * @param player The player this NPC becomes visible/invisible to * @param visible True if you want the NPC to be invisible to the player, false otherwise */ - void setVisibleTo(ScriptPlayer player, boolean visible); + void setVisibleTo(IPlayer player, boolean visible); /** * @@ -497,7 +494,7 @@ public interface ICustomNpc extends IEntityLiving { * If setVisibleTo(player,visible) was not called to make this NPC invisible to the player at any point * in the NPC's life, this function will return true regardless of the value of isVisible(). */ - boolean isVisibleTo(ScriptPlayer player); + boolean isVisibleTo(IPlayer player); /** * @param type The visibility type of the name, 0:visible, 1:invisible, 2:when-attacking @@ -621,7 +618,7 @@ public interface ICustomNpc extends IEntityLiving { * @param player The player to give the item to * @param item The item given to the player */ - void giveItem(ScriptPlayer player, ScriptItemStack item); + void giveItem(IPlayer player, IItemStack item); /** diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java index 2b9e6d624..bb517850c 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntity.java @@ -8,10 +8,9 @@ package noppes.npcs.scripted.interfaces.entity; import net.minecraft.entity.Entity; import noppes.npcs.scripted.ScriptParticle; import noppes.npcs.scripted.ScriptWorld; -import noppes.npcs.scripted.entity.ScriptEntity; import noppes.npcs.scripted.interfaces.INbt; import noppes.npcs.scripted.interfaces.IPos; -import noppes.npcs.scripted.item.ScriptItemStack; +import noppes.npcs.scripted.interfaces.item.IItemStack; public interface IEntity { @@ -129,14 +128,14 @@ public interface IEntity { * @param range The search range for entities around this entity * @return Array of entities within range */ - ScriptEntity[] getSurroundingEntities(int range); + IEntity[] getSurroundingEntities(int range); /** * @param range The search range for entities around this entity * @param type The EntityType you want to find * @return Array of entities within range */ - ScriptEntity[] getSurroundingEntities(int range, int type); + IEntity[] getSurroundingEntities(int range, int type); /** * @return Whether the entity is alive or not @@ -249,27 +248,27 @@ public interface IEntity { /** * @param item Item to be dropped */ - void dropItem(ScriptItemStack item); + void dropItem(IItemStack item); /** * @return Return the rider */ - ScriptEntity getRider(); + IEntity getRider(); /** * @param entity The entity to ride this entity */ - void setRider(ScriptEntity entity); + void setRider(IEntity entity); /** * @return Return the entity, this entity is riding */ - ScriptEntity getMount(); + IEntity getMount(); /** * @param entity The entity this entity will mount */ - void setMount(ScriptEntity entity); + void setMount(IEntity entity); /** * @see noppes.npcs.scripted.constants.EntityType diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntityLivingBase.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntityLivingBase.java index f4c000eb1..401ac854b 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntityLivingBase.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IEntityLivingBase.java @@ -1,11 +1,8 @@ package noppes.npcs.scripted.interfaces.entity; import net.minecraft.entity.EntityLivingBase; -import noppes.npcs.scripted.entity.ScriptEntity; import noppes.npcs.scripted.interfaces.item.IItemStack; -import noppes.npcs.scripted.item.ScriptItemStack; -import noppes.npcs.scripted.entity.ScriptLivingBase; -import noppes.npcs.scripted.wrapper.ScriptDamageSource; +import noppes.npcs.scripted.ScriptDamageSource; public interface IEntityLivingBase extends IEntity { /** @@ -20,7 +17,7 @@ public interface IEntityLivingBase extends IEntity extends IEntity extends IEntity extends IEntity extends IEntity extends IEntityLivingBase { @@ -103,7 +101,7 @@ public interface IPlayer extends IEntityLivingBase * @param item The item to be checked * @return How many of this item the player has */ - int inventoryItemCount(ScriptItemStack item); + int inventoryItemCount(IItemStack item); /** * @since 1.7.10d @@ -116,7 +114,7 @@ public interface IPlayer extends IEntityLivingBase * @param amount How many will be removed * @return Returns true if the items were removed succesfully. Returns false incase a bigger amount than what the player has was given */ - boolean removeItem(ScriptItemStack item, int amount); + boolean removeItem(IItemStack item, int amount); /** * @since 1.7.10c @@ -133,7 +131,7 @@ public interface IPlayer extends IEntityLivingBase * @param amount The amount of the item to be added * @return Returns whether or not it gave the item succesfully */ - boolean giveItem(ScriptItemStack item, int amount); + boolean giveItem(IItemStack item, int amount); /** * @since 1.7.10c @@ -157,7 +155,7 @@ public interface IPlayer extends IEntityLivingBase /** * @param item The item to be removed from the players inventory */ - void removeAllItems(ScriptItemStack item); + void removeAllItems(IItemStack item); void setRotation(float rotationYaw, float rotationPitch); @@ -169,11 +167,11 @@ public interface IPlayer extends IEntityLivingBase void mountEntity(Entity ridingEntity); - ScriptEntity dropOneItem(boolean dropStack); + IEntity dropOneItem(boolean dropStack); boolean canHarvestBlock(ScriptBlock block); - boolean interactWith(ScriptEntity entity); + boolean interactWith(IEntity entity); /** * @param achievement The achievement id. For a complete list see http://minecraft.gamepedia.com/Achievements diff --git a/src/main/java/noppes/npcs/scripted/interfaces/item/IItemCustom.java b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemCustom.java index e36e84907..ff6f5c8c6 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/item/IItemCustom.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/item/IItemCustom.java @@ -1,6 +1,36 @@ package noppes.npcs.scripted.interfaces.item; +import cpw.mods.fml.common.eventhandler.Event; +import noppes.npcs.constants.EnumScriptType; +import noppes.npcs.controllers.ScriptContainer; + +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + public interface IItemCustom extends IItemStack { + + void callScript(EnumScriptType type, Event event); + + boolean isClient(); + + boolean getEnabled(); + + void setEnabled(boolean bo); + + String getLanguage(); + + void setLanguage(String lang); + + List getScripts(); + + String noticeString(); + + Map getConsoleText(); + + void clearConsole(); + String getTexture(); void setTexture(String var2); diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java index ea5ddad32..3344f6fa2 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java @@ -22,11 +22,10 @@ import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.ScriptNbt; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.INbt; -import noppes.npcs.scripted.wrapper.NpcAPI; +import noppes.npcs.scripted.NpcAPI; public class ScriptItemStack implements IItemStack { public ItemStack item; - private NBTTagCompound storedData = new NBTTagCompound(); public ScriptItemStack(ItemStack item){ this.item = item; diff --git a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java index 6cd2c5293..77ec4b0b8 100644 --- a/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java +++ b/src/main/java/noppes/npcs/scripted/overlay/ScriptOverlay.java @@ -4,7 +4,6 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.controllers.CustomGuiController; -import noppes.npcs.scripted.entity.ScriptPlayer; import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.overlay.*; @@ -113,7 +112,7 @@ public class ScriptOverlay implements ICustomOverlay { } public void update(IPlayer player) { - CustomGuiController.updateOverlay((ScriptPlayer)player, this); + CustomGuiController.updateOverlay(player, this); } public ICustomOverlay fromNBT(NBTTagCompound tag) { diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptJobFollower.java b/src/main/java/noppes/npcs/scripted/roles/ScriptJobFollower.java index 610ef99e3..ddbce4dd0 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptJobFollower.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptJobFollower.java @@ -2,8 +2,8 @@ package noppes.npcs.scripted.roles; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.JobFollower; -import noppes.npcs.scripted.entity.ScriptNpc; import noppes.npcs.scripted.constants.JobType; +import noppes.npcs.scripted.interfaces.entity.ICustomNpc; public class ScriptJobFollower extends ScriptJobInterface{ private JobFollower job; @@ -20,10 +20,10 @@ public class ScriptJobFollower extends ScriptJobInterface{ job.name = name; } - public ScriptNpc getFollowingNpc(){ + public ICustomNpc getFollowingNpc(){ if(!isFollowing()) return null; - return (ScriptNpc)job.following.script.dummyNpc; + return job.following.script.dummyNpc; } public boolean isFollowing(){ diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptJobHealer.java b/src/main/java/noppes/npcs/scripted/roles/ScriptJobHealer.java index 52bcaefc9..eec32c14c 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptJobHealer.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptJobHealer.java @@ -2,8 +2,8 @@ package noppes.npcs.scripted.roles; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.JobHealer; -import noppes.npcs.scripted.entity.ScriptLivingBase; import noppes.npcs.scripted.constants.JobType; +import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; public class ScriptJobHealer extends ScriptJobInterface{ private JobHealer job; @@ -12,7 +12,7 @@ public class ScriptJobHealer extends ScriptJobInterface{ this.job = (JobHealer) npc.jobInterface; } - public void heal(ScriptLivingBase entity, float amount){ + public void heal(IEntityLivingBase entity, float amount){ job.heal(entity.getMCEntity(), amount); } diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptJobSpawner.java b/src/main/java/noppes/npcs/scripted/roles/ScriptJobSpawner.java index cf9529be8..64bc609f4 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptJobSpawner.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptJobSpawner.java @@ -3,11 +3,11 @@ package noppes.npcs.scripted.roles; import java.util.ArrayList; import net.minecraft.entity.EntityLivingBase; -import noppes.npcs.controllers.ScriptController; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.JobSpawner; -import noppes.npcs.scripted.entity.ScriptLivingBase; +import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.constants.JobType; +import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; public class ScriptJobSpawner extends ScriptJobInterface{ private JobSpawner job; @@ -26,12 +26,12 @@ public class ScriptJobSpawner extends ScriptJobInterface{ * @param number The entity going to be spawned (1-6) * @return Returns spawned entity */ - public ScriptLivingBase spawnEntity(int number){ + public IEntityLivingBase spawnEntity(int number){ EntityLivingBase base = job.spawnEntity(number); if(base == null) return null; - return (ScriptLivingBase) ScriptController.Instance.getScriptForEntity(base); + return (IEntityLivingBase) NpcAPI.Instance().getIEntity(base); } /** diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleFollower.java b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleFollower.java index d10bd8dad..d541b5ff4 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleFollower.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleFollower.java @@ -1,11 +1,11 @@ package noppes.npcs.scripted.roles; import net.minecraft.entity.player.EntityPlayer; -import noppes.npcs.controllers.ScriptController; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleFollower; -import noppes.npcs.scripted.entity.ScriptPlayer; +import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.constants.RoleType; +import noppes.npcs.scripted.interfaces.entity.IPlayer; public class ScriptRoleFollower extends ScriptRoleInterface{ private RoleFollower role; @@ -18,7 +18,7 @@ public class ScriptRoleFollower extends ScriptRoleInterface{ * @since 1.7.10c * @param player Player who is set as the owner. If null given everything resets */ - public void setOwner(ScriptPlayer player){ + public void setOwner(IPlayer player){ if(player == null || player.getMCEntity() == null){ role.setOwner(null); return; @@ -31,11 +31,11 @@ public class ScriptRoleFollower extends ScriptRoleInterface{ * @since 1.7.10c * @return Returns the followers owner. Returns null if he has no owner or the owner is offline */ - public ScriptPlayer getOwner(){ + public IPlayer getOwner(){ if(role.owner == null) return null; - return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(role.owner); + return (IPlayer) NpcAPI.Instance().getIEntity(role.owner); } /** diff --git a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java index 2110974ef..64a1d9b9c 100644 --- a/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java +++ b/src/main/java/noppes/npcs/scripted/roles/ScriptRoleTrader.java @@ -2,7 +2,7 @@ package noppes.npcs.scripted.roles; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleTrader; -import noppes.npcs.scripted.item.ScriptItemStack; +import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.constants.RoleType; import foxz.utils.Market; @@ -19,7 +19,7 @@ public class ScriptRoleTrader extends ScriptRoleInterface{ * @param currency2 Currency item number two * @param sold Item to be sold by this npc */ - public void setSellOption(int slot, ScriptItemStack currency, ScriptItemStack currency2, ScriptItemStack sold){ + public void setSellOption(int slot, IItemStack currency, IItemStack currency2, IItemStack sold){ if(sold == null || slot >= 18 || slot < 0) return; if(currency == null) @@ -42,7 +42,7 @@ public class ScriptRoleTrader extends ScriptRoleInterface{ * @param currency Currency item * @param sold Item to be sold by this npc */ - public void setSellOption(int slot, ScriptItemStack currency, ScriptItemStack sold){ + public void setSellOption(int slot, IItemStack currency, IItemStack sold){ setSellOption(slot, currency, null, sold); } diff --git a/src/main/java/noppes/npcs/scripted/wrapper/WrapperEntityData.java b/src/main/java/noppes/npcs/scripted/wrapper/WrapperEntityData.java deleted file mode 100644 index 71a2a3f5e..000000000 --- a/src/main/java/noppes/npcs/scripted/wrapper/WrapperEntityData.java +++ /dev/null @@ -1,59 +0,0 @@ -// -// Source code recreated from a .class file by IntelliJ IDEA -// (powered by FernFlower decompiler) -// - -package noppes.npcs.scripted.wrapper; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.monster.EntityMob; -import net.minecraft.entity.passive.EntityAnimal; -import net.minecraft.entity.passive.EntityTameable; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.util.ResourceLocation; -import noppes.npcs.controllers.PixelmonHelper; -import noppes.npcs.scripted.entity.*; -import noppes.npcs.scripted.interfaces.entity.IEntity; - -public class WrapperEntityData{ - public IEntity base; - private static final ResourceLocation key = new ResourceLocation("customnpcs", "entitydata"); - - public WrapperEntityData(IEntity base) { - this.base = base; - } - - public static IEntity get(Entity entity) { - if (entity == null) { - return null; - } else { - WrapperEntityData data = new WrapperEntityData(new ScriptEntity(entity)); - if (data == null) { - return getData(entity).base; - } else { - return data.base; - } - } - } - - private static WrapperEntityData getData(Entity entity) { - if (entity != null && entity.worldObj != null && !entity.worldObj.isRemote) { - if (entity instanceof EntityPlayerMP) { - return new WrapperEntityData(new ScriptPlayer((EntityPlayerMP)entity)); - } else if (PixelmonHelper.isPixelmon(entity)) { - return new WrapperEntityData(new ScriptPixelmon((EntityTameable)entity)); - } else if (entity instanceof EntityAnimal) { - return new WrapperEntityData(new ScriptAnimal((EntityAnimal)entity)); - } else if (entity instanceof EntityMob) { - return new WrapperEntityData(new ScriptMonster((EntityMob)entity)); - } else if (entity instanceof EntityLiving) { - return new WrapperEntityData(new ScriptLiving((EntityLiving)entity)); - } else if (entity instanceof EntityLivingBase) { - return new WrapperEntityData(new ScriptLivingBase((EntityLivingBase)entity)); - } - } - return null; - } -} From b20babbb3576c6dca608d5c77b8e45deccb8d1b0 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 11 May 2022 22:42:31 -0500 Subject: [PATCH 33/75] Added implementations for ScriptItemArmor, ScriptItemBlock, and ScriptItemBook, which all extend ScriptItemStack. --- .../java/noppes/npcs/scripted/NpcAPI.java | 36 ++++++++----- .../npcs/scripted/item/ScriptItemArmor.java | 11 +++- .../npcs/scripted/item/ScriptItemBlock.java | 10 +++- .../npcs/scripted/item/ScriptItemBook.java | 51 ++++++++++++++++--- .../npcs/scripted/item/ScriptItemStack.java | 12 ++++- 5 files changed, 97 insertions(+), 23 deletions(-) diff --git a/src/main/java/noppes/npcs/scripted/NpcAPI.java b/src/main/java/noppes/npcs/scripted/NpcAPI.java index f4e2d012e..6e98966b3 100644 --- a/src/main/java/noppes/npcs/scripted/NpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/NpcAPI.java @@ -20,8 +20,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import net.minecraft.item.*; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.server.MinecraftServer; import net.minecraft.util.DamageSource; @@ -48,8 +47,7 @@ import noppes.npcs.scripted.interfaces.item.IItemCustom; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.AbstractNpcAPI; import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay; -import noppes.npcs.scripted.item.ScriptCustomItem; -import noppes.npcs.scripted.item.ScriptItemStack; +import noppes.npcs.scripted.item.*; import noppes.npcs.scripted.overlay.ScriptOverlay; import noppes.npcs.util.JsonException; import noppes.npcs.util.LRUHashMap; @@ -176,21 +174,35 @@ public class NpcAPI extends AbstractNpcAPI { } public IItemStack getIItemStack(ItemStack itemstack) { - if(itemstack.getItem() instanceof ItemScripted){ - return (IItemCustom) (itemstack.stackSize > 0 ? new ScriptCustomItem(itemstack) : new ScriptCustomItem(new ItemStack(Item.getItemById(0)))); + if (itemstack.getItem() instanceof ItemScripted) { + return new ScriptCustomItem(itemstack); + } else if(itemstack.getItem() instanceof ItemArmor) { + return new ScriptItemArmor(itemstack); + } else if(itemstack.getItem() instanceof ItemBook) { + return new ScriptItemBook(itemstack); + } else if(itemstack.getItem() instanceof ItemBlock) { + return new ScriptItemBlock(itemstack); } else { - return (IItemStack) (itemstack.stackSize > 0 ? new ScriptItemStack(itemstack) : new ScriptItemStack(new ItemStack(Item.getItemById(0)))); + return new ScriptItemStack(itemstack); } } - public IItemStack createItem(String id, int damage, int size){ - Item item = (Item)Item.itemRegistry.getObject(id); - if(item == null) + public IItemStack createItem(String id, int damage, int size) { + Item item = (Item) Item.itemRegistry.getObject(id); + if (item == null) return null; - if(item instanceof ItemScripted) + + if (item instanceof ItemScripted) { return new ScriptCustomItem(new ItemStack(item, size, damage)); - else + } else if(item instanceof ItemArmor) { + return new ScriptItemArmor(new ItemStack(item, size, damage)); + } else if(item instanceof ItemBook) { + return new ScriptItemBook(new ItemStack(item, size, damage)); + } else if(item instanceof ItemBlock) { + return new ScriptItemBlock(new ItemStack(item, size, damage)); + } else { return new ScriptItemStack(new ItemStack(item, size, damage)); + } } public IWorld getIWorld(WorldServer world) { diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptItemArmor.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemArmor.java index 473db92bf..bf0c40b04 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptItemArmor.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemArmor.java @@ -1,19 +1,26 @@ package noppes.npcs.scripted.item; +import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import noppes.npcs.scripted.interfaces.item.IItemArmor; public class ScriptItemArmor extends ScriptItemStack implements IItemArmor { + protected ItemArmor armor; public ScriptItemArmor(ItemStack item) { super(item); + this.armor = (ItemArmor) item.getItem(); + } + + public int getType() { + return 3; } public int getArmorSlot() { - return 0; + return armor.armorType; } public String getArmorMaterial() { - return null; + return armor.getArmorMaterial().toString(); } } diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptItemBlock.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemBlock.java index fee327802..4aa664e85 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptItemBlock.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemBlock.java @@ -1,15 +1,23 @@ package noppes.npcs.scripted.item; +import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import noppes.npcs.scripted.interfaces.item.IItemBlock; public class ScriptItemBlock extends ScriptItemStack implements IItemBlock { + protected String blockName; public ScriptItemBlock(ItemStack item) { super(item); + Block b = Block.getBlockFromItem(item.getItem()); + this.blockName = Block.blockRegistry.getNameForObject(b); + } + + public int getType() { + return 2; } public String getBlockName() { - return null; + return blockName; } } diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java index 7c59158ad..fe3711a9d 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemBook.java @@ -1,8 +1,14 @@ package noppes.npcs.scripted.item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; import noppes.npcs.scripted.interfaces.item.IItemBook; +import java.util.ArrayList; +import java.util.List; + public class ScriptItemBook extends ScriptItemStack implements IItemBook { public ScriptItemBook(ItemStack item) { @@ -10,26 +16,57 @@ public class ScriptItemBook extends ScriptItemStack implements IItemBook { } public String[] getText() { - return new String[0]; + List list = new ArrayList(); + NBTTagList pages = this.getTag().getTagList("pages", 8); + + for(int i = 0; i < pages.tagCount(); ++i) { + list.add(pages.getStringTagAt(i)); + } + + return (String[])list.toArray(new String[list.size()]); } - public void setText(String[] var1) { + public void setText(String[] pages) { + NBTTagList list = new NBTTagList(); + if (pages != null && pages.length > 0) { + String[] var3 = pages; + int var4 = pages.length; + for(int var5 = 0; var5 < var4; ++var5) { + String page = var3[var5]; + list.appendTag(new NBTTagString(page)); + } + } + + this.getTag().setTag("pages", list); } public String getAuthor() { - return null; + return this.getTag().getString("author"); } - public void setAuthor(String var1) { - + public void setAuthor(String author) { + this.getTag().setString("author",author); } public String getTitle() { - return null; + return this.getTag().getString("title"); } - public void setTitle(String var1) { + public void setTitle(String title) { + this.getTag().setString("title",title); + } + private NBTTagCompound getTag() { + NBTTagCompound comp = this.item.getTagCompound(); + if (comp == null) { + this.item.setTagCompound(comp = new NBTTagCompound()); + } + + return comp; + } + + public int getType() { + return 1; } } diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java b/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java index 3344f6fa2..49719053e 100644 --- a/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java +++ b/src/main/java/noppes/npcs/scripted/item/ScriptItemStack.java @@ -13,11 +13,13 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTBase.NBTPrimitive; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; +import net.minecraftforge.common.IPlantable; import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.ScriptNbt; import noppes.npcs.scripted.interfaces.item.IItemStack; @@ -30,7 +32,15 @@ public class ScriptItemStack implements IItemStack { public ScriptItemStack(ItemStack item){ this.item = item; } - + + public int getType() { + if (this.item.getItem() instanceof IPlantable) { + return 5; + } else { + return this.item.getItem() instanceof ItemSword ? 4 : 0; + } + } + /** * @return The minecraft name for this item */ From 02d225a269aefdb206050b5b2b83c432191b46cf Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 11 May 2022 22:55:26 -0500 Subject: [PATCH 34/75] Fix for the "npc" field in npc events/scripts. --- src/main/java/noppes/npcs/DataScript.java | 6 +++++- src/main/java/noppes/npcs/entity/EntityNPCInterface.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/DataScript.java b/src/main/java/noppes/npcs/DataScript.java index bd790f8c2..883550e11 100644 --- a/src/main/java/noppes/npcs/DataScript.java +++ b/src/main/java/noppes/npcs/DataScript.java @@ -15,6 +15,7 @@ import noppes.npcs.controllers.ScriptContainer; import noppes.npcs.controllers.IScriptHandler; import noppes.npcs.controllers.ScriptController; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.scripted.entity.ScriptNpc; import noppes.npcs.scripted.event.ScriptEvent; import noppes.npcs.scripted.ScriptWorld; import noppes.npcs.scripted.constants.EntityType; @@ -46,7 +47,10 @@ public class DataScript implements IScriptHandler { } this.npc = npc; - dummyNpc = (ICustomNpc) NpcAPI.Instance().getIEntity(npc); + if (npc.wrappedNPC == null) { + npc.wrappedNPC = new ScriptNpc(this.npc); + } + dummyNpc = npc.wrappedNPC; if(npc.worldObj instanceof WorldServer) dummyWorld = NpcAPI.Instance().getIWorld((WorldServer) npc.worldObj);//new ScriptWorld((WorldServer) npc.worldObj); diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index d01fd270a..d576c5e8e 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -165,7 +165,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti setSize(1, 1); this.updateTasks(); - if (!this.isRemote()) { + if (!this.isRemote() && this.wrappedNPC == null) { this.wrappedNPC = new ScriptNpc<>(this); } } From 115b66d0c6154e878b12942419a185713b9cb5ce Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Fri, 13 May 2022 23:14:55 -0500 Subject: [PATCH 35/75] NPC flight fixes and a minor change to the createIItemStack function. --- .../npcs/ai/pathfinder/FlyPathFinder.java | 2 +- .../ai/pathfinder/PathNavigateFlying.java | 163 +++++++++++++++++- .../java/noppes/npcs/scripted/NpcAPI.java | 15 +- .../scripted/interfaces/AbstractNpcAPI.java | 30 ++++ 4 files changed, 193 insertions(+), 17 deletions(-) diff --git a/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java b/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java index 33a26639c..cb1490232 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java @@ -262,7 +262,7 @@ public class FlyPathFinder extends PathFinder /** * Returns a mapped point or creates and adds one */ - private final FlyPathPoint openPoint(int p_75854_1_, int p_75854_2_, int p_75854_3_) + private FlyPathPoint openPoint(int p_75854_1_, int p_75854_2_, int p_75854_3_) { int l = FlyPathPoint.makeHash(p_75854_1_, p_75854_2_, p_75854_3_); FlyPathPoint pathpoint = (FlyPathPoint)this.pointMap.lookup(l); diff --git a/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java b/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java index ce16f2b4b..affe2886c 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java @@ -1,10 +1,13 @@ package noppes.npcs.ai.pathfinder; import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.passive.EntityChicken; import net.minecraft.init.Blocks; import net.minecraft.pathfinding.PathEntity; import net.minecraft.pathfinding.PathNavigate; @@ -118,7 +121,7 @@ public class PathNavigateFlying extends PathNavigate { */ public FlyPathEntity getPathToXYZ(double p_75488_1_, double p_75488_3_, double p_75488_5_) { - return this.getEntityPathToXYZ(this.theEntity, MathHelper.floor_double(p_75488_1_), (int)p_75488_3_, MathHelper.floor_double(p_75488_5_), this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim); + return !this.canNavigate() ? null : this.getEntityPathToXYZ(this.theEntity, MathHelper.floor_double(p_75488_1_), (int)p_75488_3_, MathHelper.floor_double(p_75488_5_), this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim); } /** @@ -135,7 +138,7 @@ public class PathNavigateFlying extends PathNavigate { */ public FlyPathEntity getPathToEntityLiving(Entity p_75494_1_) { - return this.getPathEntityToEntity(this.theEntity, p_75494_1_, this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim); + return !this.canNavigate() ? null : this.getPathEntityToEntity(this.theEntity, p_75494_1_, this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim); } /** @@ -196,13 +199,26 @@ public class PathNavigateFlying extends PathNavigate { return this.currentPath; } + private boolean isInLiquid() + { + return this.theEntity.isInWater() || this.theEntity.handleLavaMovement(); + } + + private boolean canNavigate() + { + return !this.isInLiquid() || (this.canSwim && this.isInLiquid()); + } + public void onUpdateNavigation() { ++this.totalTicks; if (!this.noPath()) { - this.pathFollow(); + if (this.canNavigate()) + { + this.pathFollow(); + } if (!this.noPath()) { @@ -245,7 +261,7 @@ public class PathNavigateFlying extends PathNavigate { } } - if (this.totalTicks - this.ticksAtLastPos > 100) + if (this.totalTicks - this.ticksAtLastPos > 50) { if (vec3.squareDistanceTo(this.lastPosCheck) < 2.25D) { @@ -314,11 +330,148 @@ public class PathNavigateFlying extends PathNavigate { */ private boolean isDirectPathBetweenPoints(Vec3 p_75493_1_, Vec3 p_75493_2_, int p_75493_3_, int p_75493_4_, int p_75493_5_) { + int l = MathHelper.floor_double(p_75493_1_.xCoord); + int i1 = MathHelper.floor_double(p_75493_1_.zCoord); double d0 = p_75493_2_.xCoord - p_75493_1_.xCoord; double d1 = p_75493_2_.zCoord - p_75493_1_.zCoord; double d2 = d0 * d0 + d1 * d1; - return !(d2 < 1.0E-8D); + if (d2 < 1.0E-8D) + { + return false; + } + else + { + double d3 = 1.0D / Math.sqrt(d2); + d0 *= d3; + d1 *= d3; + p_75493_3_ += 2; + p_75493_5_ += 2; + + if (!this.isSafeToStandAt(l, (int)p_75493_1_.yCoord, i1, p_75493_3_, p_75493_4_, p_75493_5_, p_75493_1_, d0, d1)) + { + return false; + } + else + { + p_75493_3_ -= 2; + p_75493_5_ -= 2; + double d4 = 1.0D / Math.abs(d0); + double d5 = 1.0D / Math.abs(d1); + double d6 = (double)(l * 1) - p_75493_1_.xCoord; + double d7 = (double)(i1 * 1) - p_75493_1_.zCoord; + + if (d0 >= 0.0D) + { + ++d6; + } + + if (d1 >= 0.0D) + { + ++d7; + } + + d6 /= d0; + d7 /= d1; + int j1 = d0 < 0.0D ? -1 : 1; + int k1 = d1 < 0.0D ? -1 : 1; + int l1 = MathHelper.floor_double(p_75493_2_.xCoord); + int i2 = MathHelper.floor_double(p_75493_2_.zCoord); + int j2 = l1 - l; + int k2 = i2 - i1; + + do + { + if (j2 * j1 <= 0 && k2 * k1 <= 0) + { + return true; + } + + if (d6 < d7) + { + d6 += d4; + l += j1; + j2 = l1 - l; + } + else + { + d7 += d5; + i1 += k1; + k2 = i2 - i1; + } + } + while (this.isSafeToStandAt(l, (int)p_75493_1_.yCoord, i1, p_75493_3_, p_75493_4_, p_75493_5_, p_75493_1_, d0, d1)); + + return false; + } + } + } + + private boolean isSafeToStandAt(int p_75483_1_, int p_75483_2_, int p_75483_3_, int p_75483_4_, int p_75483_5_, int p_75483_6_, Vec3 p_75483_7_, double p_75483_8_, double p_75483_10_) + { + int k1 = p_75483_1_ - p_75483_4_ / 2; + int l1 = p_75483_3_ - p_75483_6_ / 2; + + if (!this.isPositionClear(k1, p_75483_2_, l1, p_75483_4_, p_75483_5_, p_75483_6_, p_75483_7_, p_75483_8_, p_75483_10_)) + { + return false; + } + else + { + for (int i2 = k1; i2 < k1 + p_75483_4_; ++i2) + { + for (int j2 = l1; j2 < l1 + p_75483_6_; ++j2) + { + double d2 = (double)i2 + 0.5D - p_75483_7_.xCoord; + double d3 = (double)j2 + 0.5D - p_75483_7_.zCoord; + + if (d2 * p_75483_8_ + d3 * p_75483_10_ >= 0.0D) + { + Block block = this.worldObj.getBlock(i2, p_75483_2_ - 1, j2); + Material material = block.getMaterial(); + + if (material == Material.water && !this.theEntity.isInWater()) + { + return false; + } + + if (material == Material.lava) + { + return false; + } + } + } + } + + return true; + } + } + + private boolean isPositionClear(int p_75496_1_, int p_75496_2_, int p_75496_3_, int p_75496_4_, int p_75496_5_, int p_75496_6_, Vec3 p_75496_7_, double p_75496_8_, double p_75496_10_) + { + for (int k1 = p_75496_1_; k1 < p_75496_1_ + p_75496_4_; ++k1) + { + for (int l1 = p_75496_2_; l1 < p_75496_2_ + p_75496_5_; ++l1) + { + for (int i2 = p_75496_3_; i2 < p_75496_3_ + p_75496_6_; ++i2) + { + double d2 = (double)k1 + 0.5D - p_75496_7_.xCoord; + double d3 = (double)i2 + 0.5D - p_75496_7_.zCoord; + + if (d2 * p_75496_8_ + d3 * p_75496_10_ >= 0.0D) + { + Block block = this.worldObj.getBlock(k1, l1, i2); + + if (!block.getBlocksMovement(this.worldObj, k1, l1, i2)) + { + return false; + } + } + } + } + } + + return true; } public FlyPathEntity getPathEntityToEntity(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_) diff --git a/src/main/java/noppes/npcs/scripted/NpcAPI.java b/src/main/java/noppes/npcs/scripted/NpcAPI.java index 6e98966b3..98c1beba8 100644 --- a/src/main/java/noppes/npcs/scripted/NpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/NpcAPI.java @@ -174,6 +174,9 @@ public class NpcAPI extends AbstractNpcAPI { } public IItemStack getIItemStack(ItemStack itemstack) { + if(itemstack == null) + return null; + if (itemstack.getItem() instanceof ItemScripted) { return new ScriptCustomItem(itemstack); } else if(itemstack.getItem() instanceof ItemArmor) { @@ -192,17 +195,7 @@ public class NpcAPI extends AbstractNpcAPI { if (item == null) return null; - if (item instanceof ItemScripted) { - return new ScriptCustomItem(new ItemStack(item, size, damage)); - } else if(item instanceof ItemArmor) { - return new ScriptItemArmor(new ItemStack(item, size, damage)); - } else if(item instanceof ItemBook) { - return new ScriptItemBook(new ItemStack(item, size, damage)); - } else if(item instanceof ItemBlock) { - return new ScriptItemBlock(new ItemStack(item, size, damage)); - } else { - return new ScriptItemStack(new ItemStack(item, size, damage)); - } + return getIItemStack(new ItemStack(item, size, damage)); } public IWorld getIWorld(WorldServer world) { diff --git a/src/main/java/noppes/npcs/scripted/interfaces/AbstractNpcAPI.java b/src/main/java/noppes/npcs/scripted/interfaces/AbstractNpcAPI.java index ebf02a7f0..013405db4 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/AbstractNpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/AbstractNpcAPI.java @@ -10,18 +10,26 @@ import java.io.File; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.eventhandler.EventBus; import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; import net.minecraft.util.DamageSource; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.WorldServer; +import noppes.npcs.controllers.*; +import noppes.npcs.scripted.gui.ScriptGui; import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.entity.IPlayer; +import noppes.npcs.scripted.interfaces.gui.ICustomGui; +import noppes.npcs.scripted.interfaces.handler.*; import noppes.npcs.scripted.interfaces.item.IItemStack; +import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay; +import noppes.npcs.scripted.overlay.ScriptOverlay; public abstract class AbstractNpcAPI { private static AbstractNpcAPI instance = null; @@ -29,6 +37,16 @@ public abstract class AbstractNpcAPI { public AbstractNpcAPI() { } + public abstract IFactionHandler getFactions(); + + public abstract IRecipeHandler getRecipes(); + + public abstract IQuestHandler getQuests(); + + public abstract IDialogHandler getDialogs(); + + public abstract ICloneHandler getClones(); + public abstract ICustomNpc createNPC(World var1); public abstract ICustomNpc spawnNPC(World var1, int var2, int var3, int var4); @@ -90,9 +108,21 @@ public abstract class AbstractNpcAPI { public abstract IItemStack createItem(String id, int damage, int size); + public abstract void playSoundAtEntity(IEntity entity, String sound, float volume, float pitch); + + public abstract void playSoundToNearExcept(IPlayer player, String sound, float volume, float pitch); + + public abstract String getMOTD(); + + public abstract void setMOTD(String motd); + public abstract IParticle createParticle(String directory); public abstract IParticle createEntityParticle(String directory); public abstract int getServerTime(); + + public abstract ICustomGui createCustomGui(int id, int width, int height, boolean pauseGame); + + public abstract ICustomOverlay createCustomOverlay(int id); } From f9f73a75d20788b8aa8e1908bfa342eaedd22242 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Sat, 14 May 2022 01:15:54 -0500 Subject: [PATCH 36/75] More fixes to flight pathing. --- .../npcs/ai/pathfinder/FlyPathFinder.java | 31 ++++++++++++++++--- .../ai/pathfinder/PathNavigateFlying.java | 16 +++++----- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java b/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java index cb1490232..2c7d2a133 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java @@ -76,10 +76,6 @@ public class FlyPathFinder extends PathFinder flag = this.isPathingInWater; this.isPathingInWater = false; } - else - { - i = MathHelper.floor_double(p_75857_1_.boundingBox.minY + 0.5D); - } FlyPathPoint pathpoint2 = this.openPoint(MathHelper.floor_double(p_75857_1_.boundingBox.minX), i, MathHelper.floor_double(p_75857_1_.boundingBox.minZ)); FlyPathPoint pathpoint = this.openPoint(MathHelper.floor_double(p_75857_2_ - (double)(p_75857_1_.width / 2.0F)), MathHelper.floor_double(p_75857_4_), MathHelper.floor_double(p_75857_6_ - (double)(p_75857_1_.width / 2.0F))); @@ -172,6 +168,13 @@ public class FlyPathFinder extends PathFinder FlyPathPoint pathpoint5 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0); FlyPathPoint pathpoint6 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord - 1, p_75860_3_, b0); + FlyPathPoint pathpoint7 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0); + + FlyPathPoint pathpoint8 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord + 1, p_75860_3_, b0); + FlyPathPoint pathpoint9 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord - 1, p_75860_3_, b0); + FlyPathPoint pathpoint10 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord - 1, p_75860_3_, b0); + FlyPathPoint pathpoint11 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord + 1, p_75860_3_, b0); + if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_) { this.pathOptions[i++] = pathpoint3; } @@ -187,6 +190,26 @@ public class FlyPathFinder extends PathFinder if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(p_75860_4_) < p_75860_5_) { this.pathOptions[i++] = pathpoint6; } + + if (pathpoint7 != null && !pathpoint7.isFirst && pathpoint7.distanceTo(p_75860_4_) < p_75860_5_) { + this.pathOptions[i++] = pathpoint7; + } + + if (pathpoint8 != null && !pathpoint8.isFirst && pathpoint8.distanceTo(p_75860_4_) < p_75860_5_) { + this.pathOptions[i++] = pathpoint8; + } + + if (pathpoint9 != null && !pathpoint9.isFirst && pathpoint9.distanceTo(p_75860_4_) < p_75860_5_) { + this.pathOptions[i++] = pathpoint9; + } + + if (pathpoint10 != null && !pathpoint10.isFirst && pathpoint10.distanceTo(p_75860_4_) < p_75860_5_) { + this.pathOptions[i++] = pathpoint10; + } + + if (pathpoint11 != null && !pathpoint11.isFirst && pathpoint11.distanceTo(p_75860_4_) < p_75860_5_) { + this.pathOptions[i++] = pathpoint11; + } } return i; diff --git a/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java b/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java index affe2886c..8bc6d4120 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java @@ -226,7 +226,7 @@ public class PathNavigateFlying extends PathNavigate { if (vec3 != null) { - this.theEntity.getMoveHelper().setMoveTo(vec3.xCoord, vec3.yCoord, vec3.zCoord, this.speed); + this.theEntity.getMoveHelper().setMoveTo(vec3.xCoord, vec3.yCoord + 0.5D, vec3.zCoord, this.speed); } } } @@ -328,7 +328,7 @@ public class PathNavigateFlying extends PathNavigate { * Returns true when an entity of specified size could safely walk in a straight line between the two points. Args: * pos1, pos2, entityXSize, entityYSize, entityZSize */ - private boolean isDirectPathBetweenPoints(Vec3 p_75493_1_, Vec3 p_75493_2_, int p_75493_3_, int p_75493_4_, int p_75493_5_) + private boolean isDirectPathBetweenPoints(Vec3 p_75493_1_, Vec3 p_75493_2_, int entityXSize, int entityYSize, int entityZSize) { int l = MathHelper.floor_double(p_75493_1_.xCoord); int i1 = MathHelper.floor_double(p_75493_1_.zCoord); @@ -345,17 +345,17 @@ public class PathNavigateFlying extends PathNavigate { double d3 = 1.0D / Math.sqrt(d2); d0 *= d3; d1 *= d3; - p_75493_3_ += 2; - p_75493_5_ += 2; + entityXSize += 2; + entityZSize += 2; - if (!this.isSafeToStandAt(l, (int)p_75493_1_.yCoord, i1, p_75493_3_, p_75493_4_, p_75493_5_, p_75493_1_, d0, d1)) + if (!this.isSafeToStandAt(l, (int)p_75493_1_.yCoord, i1, entityXSize, entityYSize, entityZSize, p_75493_1_, d0, d1)) { return false; } else { - p_75493_3_ -= 2; - p_75493_5_ -= 2; + entityXSize -= 2; + entityZSize -= 2; double d4 = 1.0D / Math.abs(d0); double d5 = 1.0D / Math.abs(d1); double d6 = (double)(l * 1) - p_75493_1_.xCoord; @@ -400,7 +400,7 @@ public class PathNavigateFlying extends PathNavigate { k2 = i2 - i1; } } - while (this.isSafeToStandAt(l, (int)p_75493_1_.yCoord, i1, p_75493_3_, p_75493_4_, p_75493_5_, p_75493_1_, d0, d1)); + while (this.isSafeToStandAt(l, (int)p_75493_1_.yCoord, i1, entityXSize, entityYSize, entityZSize, p_75493_1_, d0, d1)); return false; } From 44459a23a77ae51afb4f890af542170fd7abab96 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Sat, 14 May 2022 01:52:20 -0500 Subject: [PATCH 37/75] More fixes to flight pathing: PathNavigateFlying: Flight pathing checks if it's stuck every 10 ticks now, and clears the path to be able to path again if so. FlyPathFinder: If a point on the path is air, the path finder checks if the NPC will run into any blocks above that point due to its height. --- .../noppes/npcs/ai/pathfinder/FlyPathFinder.java | 12 +++++++++++- .../npcs/ai/pathfinder/PathNavigateFlying.java | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java b/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java index 2c7d2a133..1623bd321 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java @@ -323,7 +323,17 @@ public class FlyPathFinder extends PathFinder if(block == Blocks.air) { - return 2; + boolean heightClear = true; + for (int currentY = blockY; currentY < Math.ceil(blockY + entity.height); ++currentY) { + Block b = entity.worldObj.getBlock(l, currentY, j1); + if (b != Blocks.air) { + heightClear = false; + break; + } + } + if (heightClear) { + return 2; + } } if (block == Blocks.trapdoor) diff --git a/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java b/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java index 8bc6d4120..a00b95c13 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java @@ -261,7 +261,7 @@ public class PathNavigateFlying extends PathNavigate { } } - if (this.totalTicks - this.ticksAtLastPos > 50) + if (this.totalTicks - this.ticksAtLastPos > 10) { if (vec3.squareDistanceTo(this.lastPosCheck) < 2.25D) { From 1f79b521764e10b3c10fcbe237d9369608084b03 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Sun, 15 May 2022 01:21:06 -0500 Subject: [PATCH 38/75] More fixes for flight pathing --- src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java | 2 +- .../java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java | 3 +++ .../java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java | 2 +- src/main/java/noppes/npcs/entity/EntityNPCFlying.java | 5 +---- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java b/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java index 1623bd321..ef1263aec 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java @@ -324,7 +324,7 @@ public class FlyPathFinder extends PathFinder if(block == Blocks.air) { boolean heightClear = true; - for (int currentY = blockY; currentY < Math.ceil(blockY + entity.height); ++currentY) { + for (int currentY = blockY; currentY <= Math.ceil(blockY + entity.height); ++currentY) { Block b = entity.worldObj.getBlock(l, currentY, j1); if (b != Blocks.air) { heightClear = false; diff --git a/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java b/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java index a722b04af..0c31d46ec 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/FlyingMoveHelper.java @@ -54,6 +54,9 @@ public class FlyingMoveHelper extends EntityMoveHelper{ if (heightOffGround < this.entity.ai.flyHeightLimit || !this.entity.ai.hasFlyLimit) { this.entity.motionY = verticalSpeed * (d1 / d5); + if (this.entity.motionY > 0) { + this.entity.motionY += 0.1D; + } } this.entity.velocityChanged = true; diff --git a/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java b/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java index a00b95c13..257b2b129 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java @@ -226,7 +226,7 @@ public class PathNavigateFlying extends PathNavigate { if (vec3 != null) { - this.theEntity.getMoveHelper().setMoveTo(vec3.xCoord, vec3.yCoord + 0.5D, vec3.zCoord, this.speed); + this.theEntity.getMoveHelper().setMoveTo(vec3.xCoord, vec3.yCoord, vec3.zCoord, this.speed); } } } diff --git a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java index e588e2f93..ddfa7af4a 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java @@ -48,7 +48,7 @@ public abstract class EntityNPCFlying extends EntityNPCInterface { } } - if(heightOffGround > this.ai.flyHeightLimit && this.ai.hasFlyLimit){ + if (heightOffGround > this.ai.flyHeightLimit && this.ai.hasFlyLimit) { super.moveEntityWithHeading(p_70612_1_,p_70612_2_); return; } @@ -57,9 +57,6 @@ public abstract class EntityNPCFlying extends EntityNPCInterface { super.moveEntityWithHeading(p_70612_1_, p_70612_2_); this.motionY = d3; - this.fallDistance = 0.0F; - this.velocityChanged = true; - if(this.getNavigator().noPath()) this.motionY = 0.0D; } From ec9466c01100451d7f7cf190a0659ba10fb5233a Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Sun, 15 May 2022 01:56:00 -0500 Subject: [PATCH 39/75] Diagonal flight path options now require the two horizontal and vertical path options in an NPCs way to also be clear. --- .../npcs/ai/pathfinder/FlyPathFinder.java | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java b/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java index ef1263aec..9bb05603f 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/FlyPathFinder.java @@ -163,17 +163,17 @@ public class FlyPathFinder extends PathFinder } for(int y = -1; y <= 1; y ++) { - FlyPathPoint pathpoint3 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord + 1, p_75860_3_, b0); - FlyPathPoint pathpoint4 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0); - FlyPathPoint pathpoint5 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0); - FlyPathPoint pathpoint6 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord - 1, p_75860_3_, b0); + FlyPathPoint pathpoint3 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord + 1, p_75860_3_, b0); //A + FlyPathPoint pathpoint4 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0); //D + FlyPathPoint pathpoint5 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0); //B + FlyPathPoint pathpoint6 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord - 1, p_75860_3_, b0); //C FlyPathPoint pathpoint7 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + y, p_75860_2_.zCoord, p_75860_3_, b0); - FlyPathPoint pathpoint8 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord + 1, p_75860_3_, b0); - FlyPathPoint pathpoint9 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord - 1, p_75860_3_, b0); - FlyPathPoint pathpoint10 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord - 1, p_75860_3_, b0); - FlyPathPoint pathpoint11 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord + 1, p_75860_3_, b0); + FlyPathPoint pathpoint8 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord + 1, p_75860_3_, b0); //2 + FlyPathPoint pathpoint9 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord - 1, p_75860_3_, b0); //4 + FlyPathPoint pathpoint10 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord - 1, p_75860_3_, b0); //3 + FlyPathPoint pathpoint11 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + y, p_75860_2_.zCoord + 1, p_75860_3_, b0); //1 if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_) { this.pathOptions[i++] = pathpoint3; @@ -195,19 +195,27 @@ public class FlyPathFinder extends PathFinder this.pathOptions[i++] = pathpoint7; } - if (pathpoint8 != null && !pathpoint8.isFirst && pathpoint8.distanceTo(p_75860_4_) < p_75860_5_) { + if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_ && + pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(p_75860_4_) < p_75860_5_ && + pathpoint8 != null && !pathpoint8.isFirst && pathpoint8.distanceTo(p_75860_4_) < p_75860_5_) { this.pathOptions[i++] = pathpoint8; } - if (pathpoint9 != null && !pathpoint9.isFirst && pathpoint9.distanceTo(p_75860_4_) < p_75860_5_) { + if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(p_75860_4_) < p_75860_5_ && + pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(p_75860_4_) < p_75860_5_ && + pathpoint9 != null && !pathpoint9.isFirst && pathpoint9.distanceTo(p_75860_4_) < p_75860_5_) { this.pathOptions[i++] = pathpoint9; } - if (pathpoint10 != null && !pathpoint10.isFirst && pathpoint10.distanceTo(p_75860_4_) < p_75860_5_) { + if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(p_75860_4_) < p_75860_5_ && + pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(p_75860_4_) < p_75860_5_ && + pathpoint10 != null && !pathpoint10.isFirst && pathpoint10.distanceTo(p_75860_4_) < p_75860_5_) { this.pathOptions[i++] = pathpoint10; } - if (pathpoint11 != null && !pathpoint11.isFirst && pathpoint11.distanceTo(p_75860_4_) < p_75860_5_) { + if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_ && + pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(p_75860_4_) < p_75860_5_ && + pathpoint11 != null && !pathpoint11.isFirst && pathpoint11.distanceTo(p_75860_4_) < p_75860_5_) { this.pathOptions[i++] = pathpoint11; } } From aa9a9499aa3c28d0d60066e7720d1f5403102a1e Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Sun, 15 May 2022 16:47:48 -0500 Subject: [PATCH 40/75] Implemented custom powered textures for NPC's, overlays that can have their textures move. --- src/main/java/noppes/npcs/DataDisplay.java | 49 +++++++++- .../client/renderer/RenderNPCInterface.java | 93 +++++++++++++++---- .../npcs/entity/EntityNPCInterface.java | 2 + .../npcs/scripted/entity/ScriptNpc.java | 43 ++++++++- .../interfaces/entity/ICustomNpc.java | 4 + 5 files changed, 165 insertions(+), 26 deletions(-) diff --git a/src/main/java/noppes/npcs/DataDisplay.java b/src/main/java/noppes/npcs/DataDisplay.java index 32781013b..5ce64cd92 100644 --- a/src/main/java/noppes/npcs/DataDisplay.java +++ b/src/main/java/noppes/npcs/DataDisplay.java @@ -36,8 +36,19 @@ public class DataDisplay { public GameProfile playerProfile; public String texture = "customnpcs:textures/entity/humanmale/Steve.png"; public String cloakTexture = ""; + public String glowTexture = ""; - + public float overlaySize = 1.0F; + public float overlayScaleX = 1.0F; + public float overlayScaleY = 1.0F; + + public String poweredTexture = ""; + public float poweredSize = 1.0F; + public float poweredSpeedX = 1.0F; + public float poweredSpeedY = 1.0F; + public float poweredScaleX = 1.0F; + public float poweredScaleY = 1.0F; + public int visible = 0; //0:visible 1:Invisible 2:semi-invisible public int modelSize = 5; @@ -73,10 +84,21 @@ public class DataDisplay { nbttagcompound.setString("SkinUrl", url); nbttagcompound.setString("Texture", texture); nbttagcompound.setString("CloakTexture", cloakTexture); - nbttagcompound.setString("GlowTexture", glowTexture); nbttagcompound.setByte("UsingSkinUrl", skinType); - if (this.playerProfile != null) + nbttagcompound.setString("GlowTexture", glowTexture); + nbttagcompound.setFloat("OverlaySize", overlaySize); + nbttagcompound.setFloat("OverlayScaleX", overlayScaleX); + nbttagcompound.setFloat("OverlayScaleY", overlayScaleY); + + nbttagcompound.setString("PoweredTexture", poweredTexture); + nbttagcompound.setFloat("PoweredSize", poweredSize); + nbttagcompound.setFloat("PoweredSpeedX", poweredSpeedX); + nbttagcompound.setFloat("PoweredSpeedY", poweredSpeedY); + nbttagcompound.setFloat("PoweredScaleX", poweredScaleX); + nbttagcompound.setFloat("PoweredScaleY", poweredScaleY); + + if (this.playerProfile != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); NBTUtil.func_152460_a(nbttagcompound1, this.playerProfile); @@ -130,8 +152,27 @@ public class DataDisplay { texture = nbttagcompound.getString("Texture"); cloakTexture = nbttagcompound.getString("CloakTexture"); + + overlayScaleX = overlayScaleX == 0 ? 1.0F : overlayScaleX; + overlayScaleY = overlayScaleY == 0 ? 1.0F : overlayScaleY; + overlaySize = overlaySize == 0 ? 1.0F : overlaySize; glowTexture = nbttagcompound.getString("GlowTexture"); - + overlaySize = nbttagcompound.getFloat("OverlaySize"); + overlayScaleX = nbttagcompound.getFloat("OverlayScaleX"); + overlayScaleY = nbttagcompound.getFloat("OverlayScaleY"); + + poweredScaleX = poweredScaleX == 0 ? 1.0F : poweredScaleX; + poweredScaleY = poweredScaleY == 0 ? 1.0F : poweredScaleY; + poweredSpeedX = poweredSpeedX == 0 ? 1.0F : poweredSpeedX; + poweredSpeedY = poweredSpeedY == 0 ? 1.0F : poweredSpeedY; + poweredSize = poweredSize == 0 ? 1.0F : poweredSize; + poweredTexture = nbttagcompound.getString("PoweredTexture"); + poweredSize = nbttagcompound.getFloat("PoweredSize"); + poweredSpeedX = nbttagcompound.getFloat("PoweredSpeedX"); + poweredSpeedY = nbttagcompound.getFloat("PoweredSpeedY"); + poweredScaleX = nbttagcompound.getFloat("PoweredScaleX"); + poweredScaleY = nbttagcompound.getFloat("PoweredScaleY"); + modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE); if(modelSize > CustomNpcs.NpcSizeLimit) modelSize = CustomNpcs.NpcSizeLimit; diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index a14750ffa..9914fe4f8 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -19,6 +19,7 @@ import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.BossStatus; import net.minecraft.util.ResourceLocation; +import noppes.npcs.client.ClientProxy; import noppes.npcs.client.ImageDownloadAlt; import noppes.npcs.client.model.ModelMPM; import noppes.npcs.constants.EnumAnimation; @@ -34,7 +35,6 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; public class RenderNPCInterface extends RenderLiving{ public static long LastTextureTick = 0; - public ModelBase originalModel; public RenderNPCInterface(ModelBase model, float f){ @@ -213,43 +213,96 @@ public class RenderNPCInterface extends RenderLiving{ EntityNPCInterface npc = (EntityNPCInterface) entityliving; if (!npc.display.glowTexture.isEmpty()) { - GL11.glDepthFunc(GL11.GL_LEQUAL); if(npc.textureGlowLocation == null){ npc.textureGlowLocation = new ResourceLocation(npc.display.glowTexture); } bindTexture((ResourceLocation) npc.textureGlowLocation); float f1 = 1.0F; - GL11.glEnable(GL11.GL_BLEND); // Overlay & Glow + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); GL11.glDisable(GL11.GL_LIGHTING); - if (npc.isInvisible()) - { - GL11.glDepthMask(false); - } - else - { - GL11.glDepthMask(true); - } + GL11.glDepthMask(!npc.isInvisible()); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPushMatrix(); - GL11.glScalef(1.001f, 1.001f, 1.001f); - if(mainModel instanceof ModelMPM){ - ((ModelMPM)mainModel).isArmor = true; - mainModel.render(entityliving, par2, par3, par4, par5, par6, par7); - ((ModelMPM)mainModel).isArmor = false; - } - else - mainModel.render(entityliving, par2, par3, par4, par5, par6, par7); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glScalef(npc.display.overlayScaleX, npc.display.overlayScaleY, 1.0F); + + GL11.glMatrixMode(GL11.GL_MODELVIEW); + float scale = 1.001f * npc.display.overlaySize; + GL11.glScalef(scale, scale, scale); + if(mainModel instanceof ModelMPM){ + ((ModelMPM)mainModel).isArmor = true; + mainModel.render(entityliving, par2, par3, par4, par5, par6, par7); + ((ModelMPM)mainModel).isArmor = false; + } + else + mainModel.render(entityliving, par2, par3, par4, par5, par6, par7); GL11.glPopMatrix(); + + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glEnable(GL11.GL_LIGHTING); GL11.glColor4f(1.0F, 1.0F, 1.0F, f1); - GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDisable(GL11.GL_BLEND); } + + if (!npc.display.poweredTexture.isEmpty()) + { + if(npc.texturePoweredLocation == null){ + npc.texturePoweredLocation = new ResourceLocation(npc.display.poweredTexture); + } + + bindTexture((ResourceLocation) npc.texturePoweredLocation); + float f1 = 1.0F; + + // Overlay & Glow + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + GL11.glDisable(GL11.GL_LIGHTING); + + GL11.glDepthMask(!npc.isInvisible()); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + GL11.glPushMatrix(); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glTranslatef(npc.renderTicksPowered * 0.001F * npc.display.poweredSpeedX, npc.renderTicksPowered * 0.001F * npc.display.poweredSpeedY, 0.0F); + GL11.glScalef(npc.display.poweredScaleX, npc.display.poweredScaleY, 1.0F); + + GL11.glMatrixMode(GL11.GL_MODELVIEW); + float scale = 1.001f * npc.display.poweredSize; + GL11.glScalef(scale, scale, scale); + GL11.glEnable(GL11.GL_BLEND); + if(mainModel instanceof ModelMPM){ + ((ModelMPM)mainModel).isArmor = true; + mainModel.render(entityliving, par2, par3, par4, par5, par6, par7); + ((ModelMPM)mainModel).isArmor = false; + } + else + mainModel.render(entityliving, par2, par3, par4, par5, par6, par7); + GL11.glPopMatrix(); + + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glColor4f(1.0F, 1.0F, 1.0F, f1); + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glDisable(GL11.GL_BLEND); + + npc.renderTicksPowered++; + } } @Override protected float handleRotationFloat(EntityLivingBase par1EntityLiving, float par2){ diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index d576c5e8e..164b7c95c 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -120,6 +120,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti public long totalTicksAlive = 0; private int taskCount = 1; public int lastInteract = 0; + public long renderTicksPowered = 0; public Faction faction; //should only be used server side @@ -130,6 +131,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti public ResourceLocation textureLocation = null; public ResourceLocation textureGlowLocation = null; + public ResourceLocation texturePoweredLocation = null; public ResourceLocation textureCloakLocation = null; public EnumAnimation currentAnimation = EnumAnimation.NONE; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index a6b28e496..d9e85f426 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -1098,10 +1098,49 @@ public class ScriptNpc extends ScriptLiving imp npc.display.glowTexture = overlayTexture; npc.updateClient = true; } + public String getOverlayTexture() {return npc.display.glowTexture;} - public String getOverlayTexture() { - return npc.display.glowTexture; + public void setOverlaySize(float size) { + npc.display.overlaySize = size; + npc.updateClient = true; } + public float getOverlaySize() {return npc.display.overlaySize;} + + public void setOverlayScale(float scaleX, float scaleY) { + npc.display.overlayScaleX = scaleX; + npc.display.overlayScaleY = scaleY; + npc.updateClient = true; + } + public float getOverlayTextureScaleX() {return npc.display.overlayScaleX;} + public float getOverlayTextureScaleY() {return npc.display.overlayScaleY;} + + public void setPoweredTexture(String poweredTexture) { + npc.display.poweredTexture = poweredTexture; + npc.updateClient = true; + } + public String getPoweredTexture() {return npc.display.poweredTexture;} + + public void setPoweredSize(float size) { + npc.display.poweredSize = size; + npc.updateClient = true; + } + public float getPoweredSize() {return npc.display.poweredSize;} + + public void setPoweredScale(float scaleX, float scaleY) { + npc.display.poweredScaleX = scaleX; + npc.display.poweredScaleY = scaleY; + npc.updateClient = true; + } + public float getPoweredTextureScaleX() {return npc.display.poweredScaleX;} + public float getPoweredTextureScaleY() {return npc.display.poweredScaleY;} + + public void setPoweredSpeed(float speedX, float speedY) { + npc.display.poweredSpeedX = speedX; + npc.display.poweredSpeedY = speedY; + npc.updateClient = true; + } + public float getPoweredSpeedX() {return npc.display.poweredSpeedX;} + public float getPoweredSpeedY() {return npc.display.poweredSpeedY;} public void setCollisionType(int type){ npc.display.collidesWith = type; diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java index 8b9efff78..7d3fef7fd 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java @@ -738,6 +738,10 @@ public interface ICustomNpc extends IEntityLiving { String getOverlayTexture(); + void setPoweredTexture(String poweredTexture); + + String getPoweredTexture(); + void setCollisionType(int type); int getCollisionType(); From 89ac9f52257bb36fc2966ee5807d4fad7fb3280d Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Mon, 16 May 2022 00:42:40 -0500 Subject: [PATCH 41/75] Fix for the global script GUI menu. --- .../java/noppes/npcs/PacketHandlerServer.java | 20 +++++++++++++++++++ .../client/gui/script/GuiScriptGlobal.java | 17 +++++++++++----- .../npcs/constants/EnumPacketServer.java | 3 +++ .../java/noppes/npcs/scripted/NpcAPI.java | 20 +++++++++++++++++++ 4 files changed, 55 insertions(+), 5 deletions(-) diff --git a/src/main/java/noppes/npcs/PacketHandlerServer.java b/src/main/java/noppes/npcs/PacketHandlerServer.java index 8e7a5f64b..fe4b10378 100644 --- a/src/main/java/noppes/npcs/PacketHandlerServer.java +++ b/src/main/java/noppes/npcs/PacketHandlerServer.java @@ -126,6 +126,8 @@ public class PacketHandlerServer{ forgeScriptPackets(type, buffer, player); else if (type == EnumPacketServer.ScriptItemDataGet || type == EnumPacketServer.ScriptItemDataSave) itemScriptPackets(type, buffer, player); + else if (type == EnumPacketServer.ScriptGlobalGuiDataGet || type == EnumPacketServer.ScriptGlobalGuiDataSave) + getScriptsEnabled(type, buffer, player); else if (item.getItem() == CustomItems.scripter) scriptPackets(type, buffer, player, npc); else if (item.getItem() == Item.getItemFromBlock(CustomItems.waypoint) || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock)) @@ -141,6 +143,24 @@ public class PacketHandlerServer{ NoppesUtilServer.isGUIOpen(buffer, player); } + private void getScriptsEnabled(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException { + if (type == EnumPacketServer.ScriptGlobalGuiDataGet) { + NBTTagCompound compound = new NBTTagCompound(); + compound.setBoolean("ScriptsEnabled", CustomNpcs.GlobalPlayerScripts); + compound.setBoolean("PlayerScriptsEnabled", CustomNpcs.GlobalPlayerScripts); + compound.setBoolean("GlobalNPCScriptsEnabled", CustomNpcs.GlobalNPCScripts); + compound.setBoolean("ForgeScriptsEnabled", CustomNpcs.GlobalForgeScripts); + Server.sendData(player, EnumPacketClient.GUI_DATA, compound); + } + else if (type == EnumPacketServer.ScriptGlobalGuiDataSave) { + NBTTagCompound compound = Server.readNBT(buffer); + CustomNpcs.GlobalPlayerScripts = compound.getBoolean("ScriptsEnabled"); + CustomNpcs.GlobalPlayerScripts = compound.getBoolean("PlayerScriptsEnabled"); + CustomNpcs.GlobalNPCScripts = compound.getBoolean("GlobalNPCScriptsEnabled"); + CustomNpcs.GlobalForgeScripts = compound.getBoolean("ForgeScriptsEnabled"); + } + } + private void scriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws Exception { if(type == EnumPacketServer.ScriptDataSave){ npc.script.readFromNBT(Server.readNBT(buffer)); diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptGlobal.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptGlobal.java index 23e37689f..5eb022c92 100644 --- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptGlobal.java +++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptGlobal.java @@ -6,13 +6,16 @@ package noppes.npcs.client.gui.script; import net.minecraft.client.gui.GuiButton; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; -import noppes.npcs.CustomNpcs; +import noppes.npcs.client.Client; import noppes.npcs.client.gui.util.GuiNPCInterface; import noppes.npcs.client.gui.util.GuiNpcButton; +import noppes.npcs.client.gui.util.IGuiData; +import noppes.npcs.constants.EnumPacketServer; import org.lwjgl.opengl.GL11; -public class GuiScriptGlobal extends GuiNPCInterface { +public class GuiScriptGlobal extends GuiNPCInterface implements IGuiData { private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/smallbg.png"); public GuiScriptGlobal() { @@ -24,16 +27,20 @@ public class GuiScriptGlobal extends GuiNPCInterface { public void initGui() { super.initGui(); + Client.sendData(EnumPacketServer.ScriptGlobalGuiDataGet, new Object[0]); + } + + public void setGuiData(NBTTagCompound compound) { GuiNpcButton playerButton = new GuiNpcButton(0, this.guiLeft + 38, this.guiTop + 20, 100, 20, "Players"); - playerButton.setEnabled(CustomNpcs.GlobalPlayerScripts && CustomNpcs.ScriptingEnabled); + playerButton.setEnabled(compound.getBoolean("PlayerScriptsEnabled") && compound.getBoolean("ScriptsEnabled")); this.addButton(playerButton); GuiNpcButton forgeButton = new GuiNpcButton(1, this.guiLeft + 38, this.guiTop + 50, 100, 20, "Forge"); - forgeButton.setEnabled(CustomNpcs.GlobalForgeScripts && CustomNpcs.ScriptingEnabled); + forgeButton.setEnabled(compound.getBoolean("ForgeScriptsEnabled") && compound.getBoolean("ScriptsEnabled")); this.addButton(forgeButton); GuiNpcButton npcButton = new GuiNpcButton(2, this.guiLeft + 38, this.guiTop + 80, 100, 20, "All NPCs"); - npcButton.setEnabled(CustomNpcs.GlobalNPCScripts && CustomNpcs.ScriptingEnabled); + npcButton.setEnabled(compound.getBoolean("GlobalNPCScriptsEnabled") && compound.getBoolean("ScriptsEnabled")); this.addButton(npcButton); } diff --git a/src/main/java/noppes/npcs/constants/EnumPacketServer.java b/src/main/java/noppes/npcs/constants/EnumPacketServer.java index 415f94855..d84364ca0 100644 --- a/src/main/java/noppes/npcs/constants/EnumPacketServer.java +++ b/src/main/java/noppes/npcs/constants/EnumPacketServer.java @@ -34,6 +34,9 @@ public enum EnumPacketServer { ClonePreSave(CustomNpcsPermissions.NPC_CLONE), CloneSave(CustomNpcsPermissions.NPC_CLONE), CloneRemove(CustomNpcsPermissions.NPC_CLONE), CloneList, + ScriptGlobalGuiDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, false), + ScriptGlobalGuiDataGet(false), + ScriptPlayerSave(CustomNpcsPermissions.TOOL_SCRIPTER, false), ScriptPlayerGet(false), diff --git a/src/main/java/noppes/npcs/scripted/NpcAPI.java b/src/main/java/noppes/npcs/scripted/NpcAPI.java index 98c1beba8..35eff98b7 100644 --- a/src/main/java/noppes/npcs/scripted/NpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/NpcAPI.java @@ -320,6 +320,26 @@ public class NpcAPI extends AbstractNpcAPI { return new ScriptGui(id, width, height, pauseGame); } + public boolean arePlayerScriptsEnabled() { + return CustomNpcs.GlobalPlayerScripts; + } + public boolean areForgeScriptsEnabled() { + return CustomNpcs.GlobalForgeScripts; + } + public boolean areGlobalNPCScriptsEnabled() { + return CustomNpcs.GlobalNPCScripts; + } + + public void enablePlayerScripts(boolean enable) { + CustomNpcs.GlobalPlayerScripts = enable; + } + public void enableForgeScripts(boolean enable) { + CustomNpcs.GlobalForgeScripts = enable; + } + public void enableGlobalNPCScripts(boolean enable) { + CustomNpcs.GlobalNPCScripts = enable; + } + public ICustomOverlay createCustomOverlay(int id) { return new ScriptOverlay(id); } From d82b9c972e6096d1aa66bd81a91a3ad7350763a9 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Mon, 16 May 2022 00:53:07 -0500 Subject: [PATCH 42/75] Fix for enabling/disabling global scripts. --- src/main/java/noppes/npcs/PacketHandlerServer.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/noppes/npcs/PacketHandlerServer.java b/src/main/java/noppes/npcs/PacketHandlerServer.java index fe4b10378..288e61bc5 100644 --- a/src/main/java/noppes/npcs/PacketHandlerServer.java +++ b/src/main/java/noppes/npcs/PacketHandlerServer.java @@ -179,6 +179,7 @@ public class PacketHandlerServer{ if(type == EnumPacketServer.ScriptPlayerGet) { PlayerDataScript data = ScriptController.Instance.playerScripts; compound = data.writeToNBT(new NBTTagCompound()); + compound.setBoolean("ScriptEnabled", ScriptController.Instance.playerScripts.getEnabled()); compound.setTag("Languages", ScriptController.Instance.nbtLanguages()); Server.sendData(player, EnumPacketClient.GUI_DATA, compound); } else if(type == EnumPacketServer.ScriptPlayerSave) { @@ -191,6 +192,7 @@ public class PacketHandlerServer{ if (type == EnumPacketServer.ScriptForgeGet) { ForgeDataScript data = ScriptController.Instance.forgeScripts; compound = data.writeToNBT(new NBTTagCompound()); + compound.setBoolean("ScriptEnabled", ScriptController.Instance.forgeScripts.getEnabled()); compound.setTag("Languages", ScriptController.Instance.nbtLanguages()); Server.sendData(player, EnumPacketClient.GUI_DATA, new Object[]{compound}); } else if (type == EnumPacketServer.ScriptForgeSave) { @@ -203,6 +205,7 @@ public class PacketHandlerServer{ if(type == EnumPacketServer.ScriptNPCGet) { NPCDataScript data = ScriptController.Instance.npcScripts; compound = data.writeToNBT(new NBTTagCompound()); + compound.setBoolean("ScriptEnabled", ScriptController.Instance.npcScripts.getEnabled()); compound.setTag("Languages", ScriptController.Instance.nbtLanguages()); Server.sendData(player, EnumPacketClient.GUI_DATA, compound); } else if(type == EnumPacketServer.ScriptNPCSave) { From 71aff8f78f2ce86e503de486a7bab785a5ae8bf9 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Mon, 16 May 2022 01:22:33 -0500 Subject: [PATCH 43/75] Fix for updating overlay and powered textures. --- .../npcs/client/renderer/RenderNPCInterface.java | 11 +++++++++++ .../java/noppes/npcs/scripted/entity/ScriptNpc.java | 9 ++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index 9914fe4f8..89f2bc4db 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -215,7 +215,13 @@ public class RenderNPCInterface extends RenderLiving{ { if(npc.textureGlowLocation == null){ npc.textureGlowLocation = new ResourceLocation(npc.display.glowTexture); + } else { + String locationString = npc.textureGlowLocation.getResourceDomain() + ":" + npc.textureGlowLocation.getResourcePath(); + if (!locationString.equals(npc.display.glowTexture)) { + npc.textureGlowLocation = new ResourceLocation(npc.display.glowTexture); + } } + bindTexture((ResourceLocation) npc.textureGlowLocation); float f1 = 1.0F; @@ -259,6 +265,11 @@ public class RenderNPCInterface extends RenderLiving{ { if(npc.texturePoweredLocation == null){ npc.texturePoweredLocation = new ResourceLocation(npc.display.poweredTexture); + } else { + String locationString = npc.texturePoweredLocation.getResourceDomain() + ":" + npc.texturePoweredLocation.getResourcePath(); + if (!locationString.equals(npc.display.poweredTexture)) { + npc.texturePoweredLocation = new ResourceLocation(npc.display.poweredTexture); + } } bindTexture((ResourceLocation) npc.texturePoweredLocation); diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index d9e85f426..58f416ad2 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -1096,40 +1096,36 @@ public class ScriptNpc extends ScriptLiving imp public void setOverlayTexture(String overlayTexture) { npc.display.glowTexture = overlayTexture; - npc.updateClient = true; + npc.script.clientNeedsUpdate = true; } public String getOverlayTexture() {return npc.display.glowTexture;} public void setOverlaySize(float size) { npc.display.overlaySize = size; - npc.updateClient = true; } public float getOverlaySize() {return npc.display.overlaySize;} public void setOverlayScale(float scaleX, float scaleY) { npc.display.overlayScaleX = scaleX; npc.display.overlayScaleY = scaleY; - npc.updateClient = true; } public float getOverlayTextureScaleX() {return npc.display.overlayScaleX;} public float getOverlayTextureScaleY() {return npc.display.overlayScaleY;} public void setPoweredTexture(String poweredTexture) { npc.display.poweredTexture = poweredTexture; - npc.updateClient = true; + npc.script.clientNeedsUpdate = true; } public String getPoweredTexture() {return npc.display.poweredTexture;} public void setPoweredSize(float size) { npc.display.poweredSize = size; - npc.updateClient = true; } public float getPoweredSize() {return npc.display.poweredSize;} public void setPoweredScale(float scaleX, float scaleY) { npc.display.poweredScaleX = scaleX; npc.display.poweredScaleY = scaleY; - npc.updateClient = true; } public float getPoweredTextureScaleX() {return npc.display.poweredScaleX;} public float getPoweredTextureScaleY() {return npc.display.poweredScaleY;} @@ -1137,7 +1133,6 @@ public class ScriptNpc extends ScriptLiving imp public void setPoweredSpeed(float speedX, float speedY) { npc.display.poweredSpeedX = speedX; npc.display.poweredSpeedY = speedY; - npc.updateClient = true; } public float getPoweredSpeedX() {return npc.display.poweredSpeedX;} public float getPoweredSpeedY() {return npc.display.poweredSpeedY;} From a4a013387ee9daae88a9aae1cf8feaaf022104f2 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Mon, 16 May 2022 04:08:22 -0500 Subject: [PATCH 44/75] Cloaks are now share visibility with NPCs main model. --- .../noppes/npcs/client/renderer/RenderNPCHumanMale.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java index f608a0703..b2ef80bab 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCHumanMale.java @@ -168,7 +168,7 @@ public class RenderNPCHumanMale extends RenderNPCInterface int j = i % 65536; int k = i / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); - if (!npc.display.cloakTexture.isEmpty()) + if (!npc.display.cloakTexture.isEmpty() && !npc.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) { if(npc.textureCloakLocation == null){ npc.textureCloakLocation = new ResourceLocation(npc.display.cloakTexture); @@ -199,9 +199,11 @@ public class RenderNPCHumanMale extends RenderNPCInterface GL11.glRotatef(f15 / 2.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(-f15 / 2.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); + GL11.glColor4f(1.0F,1.0F,1.0F, npc.isInvisible() ? 0.2F : 1.0F); + GL11.glEnable(GL11.GL_BLEND); modelBipedMain.renderCloak(0.0625F); - GL11.glPopMatrix(); + GL11.glDisable(GL11.GL_BLEND); } GL11.glColor3f(1,1,1); ItemStack itemstack = npc.inventory.armorItemInSlot(0); From d6b1dba9bcaa6fb5369c415d959eab7315d306b8 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Mon, 16 May 2022 04:11:31 -0500 Subject: [PATCH 45/75] Overlays and powered effects now also share visibility with NPCs. --- .../noppes/npcs/client/renderer/RenderNPCInterface.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index 89f2bc4db..68bc2bb17 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -211,7 +211,7 @@ public class RenderNPCInterface extends RenderLiving{ protected void renderModel(EntityLivingBase entityliving, float par2, float par3, float par4, float par5, float par6, float par7){ super.renderModel(entityliving, par2, par3, par4, par5, par6, par7); EntityNPCInterface npc = (EntityNPCInterface) entityliving; - if (!npc.display.glowTexture.isEmpty()) + if (!npc.display.glowTexture.isEmpty() && !npc.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) { if(npc.textureGlowLocation == null){ npc.textureGlowLocation = new ResourceLocation(npc.display.glowTexture); @@ -232,7 +232,7 @@ public class RenderNPCInterface extends RenderLiving{ GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthMask(!npc.isInvisible()); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, npc.isInvisible() ? 0.2F : 1.0F); GL11.glPushMatrix(); GL11.glMatrixMode(GL11.GL_TEXTURE); @@ -261,7 +261,7 @@ public class RenderNPCInterface extends RenderLiving{ GL11.glDisable(GL11.GL_BLEND); } - if (!npc.display.poweredTexture.isEmpty()) + if (!npc.display.poweredTexture.isEmpty() && !npc.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) { if(npc.texturePoweredLocation == null){ npc.texturePoweredLocation = new ResourceLocation(npc.display.poweredTexture); @@ -282,7 +282,7 @@ public class RenderNPCInterface extends RenderLiving{ GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthMask(!npc.isInvisible()); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, npc.isInvisible() ? 0.2F : 1.0F); GL11.glPushMatrix(); GL11.glMatrixMode(GL11.GL_TEXTURE); From 9a0aae50e0a93633ffabc8fdf75236e11e46424f Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Mon, 16 May 2022 05:45:00 -0500 Subject: [PATCH 46/75] Implemented custom player overlays. --- src/main/java/noppes/npcs/client/Client.java | 2 + .../java/noppes/npcs/client/ClientProxy.java | 2 +- .../npcs/client/PacketHandlerClient.java | 7 + .../client/renderer/RenderCNPCPlayer.java | 121 ++++++++++++++++++ .../npcs/constants/EnumPacketClient.java | 3 +- .../npcs/scripted/entity/ScriptPlayer.java | 4 + 6 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java diff --git a/src/main/java/noppes/npcs/client/Client.java b/src/main/java/noppes/npcs/client/Client.java index cb37e5d72..53530e142 100644 --- a/src/main/java/noppes/npcs/client/Client.java +++ b/src/main/java/noppes/npcs/client/Client.java @@ -6,6 +6,7 @@ import io.netty.buffer.Unpooled; import java.io.IOException; import java.util.HashMap; +import net.minecraft.util.ResourceLocation; import noppes.npcs.CustomNpcs; import noppes.npcs.Server; import noppes.npcs.client.gui.customoverlay.OverlayCustom; @@ -14,6 +15,7 @@ import cpw.mods.fml.common.network.internal.FMLProxyPacket; public class Client { public static HashMap customOverlays = new HashMap<>(); + public static ResourceLocation playerOverlay = null; public static void sendData(EnumPacketServer enu, Object... obs) { ByteBuf buffer = Unpooled.buffer(); diff --git a/src/main/java/noppes/npcs/client/ClientProxy.java b/src/main/java/noppes/npcs/client/ClientProxy.java index e0b6b07b9..caa5fc0a4 100644 --- a/src/main/java/noppes/npcs/client/ClientProxy.java +++ b/src/main/java/noppes/npcs/client/ClientProxy.java @@ -166,7 +166,7 @@ public class ClientProxy extends CommonProxy { RenderingRegistry.registerEntityRenderingHandler(EntityProjectile.class, new RenderProjectile()); RenderingRegistry.registerEntityRenderingHandler(EntityCustomNpc.class, new RenderCustomNpc()); - + RenderingRegistry.registerEntityRenderingHandler(EntityPlayer.class, new RenderCNPCPlayer()); RenderingRegistry.registerEntityRenderingHandler(EntityNPCGolem.class, new RenderNPCHumanMale( new ModelNPCGolem(0), new ModelNPCGolem(1F), new ModelNPCGolem(0.5F))); diff --git a/src/main/java/noppes/npcs/client/PacketHandlerClient.java b/src/main/java/noppes/npcs/client/PacketHandlerClient.java index d3cfca705..0493ab8bf 100644 --- a/src/main/java/noppes/npcs/client/PacketHandlerClient.java +++ b/src/main/java/noppes/npcs/client/PacketHandlerClient.java @@ -16,6 +16,7 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.network.PacketBuffer; import net.minecraft.stats.Achievement; import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraft.village.MerchantRecipeList; import noppes.npcs.CustomNpcs; @@ -273,5 +274,11 @@ public class PacketHandlerClient extends PacketHandlerServer{ else if(type == EnumPacketClient.SWING_PLAYER_ARM){ Minecraft.getMinecraft().thePlayer.swingItem(); } + else if(type == EnumPacketClient.PLAYER_OVERLAY) { + String overlayString = Server.readString(buffer); + if (overlayString != null) { + Client.playerOverlay = new ResourceLocation(overlayString); + } + } } } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java new file mode 100644 index 000000000..199dd3a85 --- /dev/null +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -0,0 +1,121 @@ +package noppes.npcs.client.renderer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import noppes.npcs.client.Client; +import org.lwjgl.opengl.GL11; + +public class RenderCNPCPlayer extends RenderPlayer { + + public RenderCNPCPlayer() { + } + + @Override + protected void renderModel(EntityLivingBase p_77036_1_, float p_77036_2_, float p_77036_3_, float p_77036_4_, float p_77036_5_, float p_77036_6_, float p_77036_7_) { + this.bindEntityTexture(p_77036_1_); + + if (!p_77036_1_.isInvisible()) + { + this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); + + if (Client.playerOverlay != null) { + try { + this.bindTexture(Client.playerOverlay); + float f1 = 1.0F; + // Overlay & Glow + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + GL11.glDisable(GL11.GL_LIGHTING); + + GL11.glDepthMask(!p_77036_1_.isInvisible()); + + GL11.glPushMatrix(); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glScalef(1.0F, 1.0F, 1.0F); + + GL11.glMatrixMode(GL11.GL_MODELVIEW); + float scale = 1.001f; + GL11.glScalef(scale, scale, scale); + this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); + GL11.glPopMatrix(); + + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glColor4f(1.0F, 1.0F, 1.0F, f1); + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glDisable(GL11.GL_BLEND); + } catch (Exception ignored) {} + } + } + else if (!p_77036_1_.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) + { + GL11.glPushMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.15F); + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); + this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); + GL11.glDisable(GL11.GL_BLEND); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glPopMatrix(); + GL11.glDepthMask(true); + } + else + { + this.mainModel.setRotationAngles(p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_, p_77036_1_); + } + } + + public void renderFirstPersonArm(EntityPlayer p_82441_1_) + { + float f = 1.0F; + GL11.glColor3f(f, f, f); + this.modelBipedMain.onGround = 0.0F; + this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, p_82441_1_); + this.modelBipedMain.bipedRightArm.render(0.0625F); + + if (Client.playerOverlay != null) { + try { + this.bindTexture(Client.playerOverlay); + float f1 = 1.0F; + // Overlay & Glow + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + GL11.glDisable(GL11.GL_LIGHTING); + + GL11.glDepthMask(!p_82441_1_.isInvisible()); + + GL11.glPushMatrix(); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glScalef(1.0F, 1.0F, 1.0F); + + GL11.glMatrixMode(GL11.GL_MODELVIEW); + float scale = 1.001f; + GL11.glScalef(scale, scale, scale); + GL11.glColor3f(1.0F, 1.0F, 1.0F); + this.modelBipedMain.onGround = 0.0F; + this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, p_82441_1_); + this.modelBipedMain.bipedRightArm.render(0.0625F); + GL11.glPopMatrix(); + + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glColor4f(1.0F, 1.0F, 1.0F, f1); + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glDisable(GL11.GL_BLEND); + } catch (Exception ignored) {} + } + } +} diff --git a/src/main/java/noppes/npcs/constants/EnumPacketClient.java b/src/main/java/noppes/npcs/constants/EnumPacketClient.java index 4629cb35a..d3c312f7b 100644 --- a/src/main/java/noppes/npcs/constants/EnumPacketClient.java +++ b/src/main/java/noppes/npcs/constants/EnumPacketClient.java @@ -37,5 +37,6 @@ public enum EnumPacketClient { OVERLAY_DATA, OVERLAY_CLOSE, SWING_PLAYER_ARM, - UPDATE_ITEM + UPDATE_ITEM, + PLAYER_OVERLAY } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index e1bdf8721..a79d3c204 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -526,6 +526,10 @@ public class ScriptPlayer extends ScriptLivingBase Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.OVERLAY_CLOSE, id, new NBTTagCompound()); } + public void setPlayerOverlay(String texture) { + Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.PLAYER_OVERLAY, texture); + } + public IQuest[] getFinishedQuests() { PlayerQuestData data = this.getData().questData; List quests = new ArrayList(); From dbfbab7be2f540cc768cc5031ca1b09846afc345 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Mon, 16 May 2022 18:47:16 -0500 Subject: [PATCH 47/75] Players can now have multiple skin overlays, just like GUI overlays. --- .../java/noppes/npcs/PacketHandlerServer.java | 8 ++ .../noppes/npcs/ScriptPlayerEventHandler.java | 16 +++ src/main/java/noppes/npcs/client/Client.java | 4 +- .../java/noppes/npcs/client/NoppesUtil.java | 15 ++ .../npcs/client/PacketHandlerClient.java | 8 +- .../client/renderer/RenderCNPCPlayer.java | 129 +++++++++--------- .../npcs/constants/EnumPacketClient.java | 2 +- .../npcs/constants/EnumPacketServer.java | 4 +- .../controllers/data/SkinOverlayData.java | 11 ++ .../npcs/scripted/entity/ScriptPlayer.java | 41 +++++- 10 files changed, 162 insertions(+), 76 deletions(-) create mode 100644 src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java diff --git a/src/main/java/noppes/npcs/PacketHandlerServer.java b/src/main/java/noppes/npcs/PacketHandlerServer.java index 288e61bc5..576d69ffb 100644 --- a/src/main/java/noppes/npcs/PacketHandlerServer.java +++ b/src/main/java/noppes/npcs/PacketHandlerServer.java @@ -128,6 +128,8 @@ public class PacketHandlerServer{ itemScriptPackets(type, buffer, player); else if (type == EnumPacketServer.ScriptGlobalGuiDataGet || type == EnumPacketServer.ScriptGlobalGuiDataSave) getScriptsEnabled(type, buffer, player); + else if (type == EnumPacketServer.SERVER_UPDATE_SKIN_OVERLAYS) + updateSkinOverlays(player); else if (item.getItem() == CustomItems.scripter) scriptPackets(type, buffer, player, npc); else if (item.getItem() == Item.getItemFromBlock(CustomItems.waypoint) || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock)) @@ -143,6 +145,12 @@ public class PacketHandlerServer{ NoppesUtilServer.isGUIOpen(buffer, player); } + public void updateSkinOverlays(EntityPlayerMP player) { + NBTTagCompound data = new NBTTagCompound(); + data.setTag("SkinOverlayData",player.getEntityData().getTagList("SkinOverlayData",10)); + Server.sendData(player, EnumPacketClient.CLIENT_UPDATE_SKIN_OVERLAYS, data); + } + private void getScriptsEnabled(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException { if (type == EnumPacketServer.ScriptGlobalGuiDataGet) { NBTTagCompound compound = new NBTTagCompound(); diff --git a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java index 97962af24..75d81209a 100644 --- a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java @@ -12,7 +12,10 @@ import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.relauncher.Side; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.ContainerPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; @@ -26,6 +29,7 @@ import net.minecraftforge.event.entity.living.LivingFallEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.player.*; import net.minecraftforge.event.world.*; +import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumQuestType; import noppes.npcs.controllers.*; import noppes.npcs.controllers.data.PlayerDataScript; @@ -33,6 +37,8 @@ import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.entity.IPlayer; +import java.util.List; + public class ScriptPlayerEventHandler { public ScriptPlayerEventHandler() { } @@ -426,6 +432,16 @@ public class ScriptPlayerEventHandler { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerLogin(handler, scriptPlayer); + + //Loads other players' and own player's skin overlays if they have them + List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; + for (EntityPlayerMP playerMP : list) { + if (playerMP.getEntityData().hasKey("SkinOverlayData")) { + NBTTagCompound data = new NBTTagCompound(); + data.setTag("SkinOverlayData",playerMP.getEntityData().getTagList("SkinOverlayData",10)); + Server.sendData(playerMP, EnumPacketClient.CLIENT_UPDATE_SKIN_OVERLAYS, data); + } + } } } diff --git a/src/main/java/noppes/npcs/client/Client.java b/src/main/java/noppes/npcs/client/Client.java index 53530e142..0e801c6b9 100644 --- a/src/main/java/noppes/npcs/client/Client.java +++ b/src/main/java/noppes/npcs/client/Client.java @@ -5,6 +5,7 @@ import io.netty.buffer.Unpooled; import java.io.IOException; import java.util.HashMap; +import java.util.UUID; import net.minecraft.util.ResourceLocation; import noppes.npcs.CustomNpcs; @@ -12,10 +13,11 @@ import noppes.npcs.Server; import noppes.npcs.client.gui.customoverlay.OverlayCustom; import noppes.npcs.constants.EnumPacketServer; import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import noppes.npcs.controllers.data.SkinOverlayData; public class Client { public static HashMap customOverlays = new HashMap<>(); - public static ResourceLocation playerOverlay = null; + public static HashMap> skinOverlays = new HashMap<>(); public static void sendData(EnumPacketServer enu, Object... obs) { ByteBuf buffer = Unpooled.buffer(); diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index 110ecf88c..253293b48 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -15,6 +15,7 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Util; @@ -35,6 +36,7 @@ import noppes.npcs.constants.EnumPlayerPacket; import noppes.npcs.controllers.Dialog; import noppes.npcs.controllers.DialogController; import noppes.npcs.controllers.Quest; +import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.Sys; @@ -70,6 +72,19 @@ public class NoppesUtil { } } + public static void updateSkinOverlayData(EntityPlayer player, NBTTagCompound compound) { + HashMap skinOverlays = new HashMap<>(); + NBTTagList skinOverlayList = compound.getTagList("SkinOverlayData",10); + + for (int i = 0; i < skinOverlayList.tagCount(); i++) { + int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID"); + String tagString = skinOverlayList.getCompoundTagAt(i).getString("SkinOverlayTexture"); + + skinOverlays.put(tagID,new SkinOverlayData(new ResourceLocation(tagString))); + } + Client.skinOverlays.put(player.getUniqueID(), skinOverlays); + } + public static void spawnScriptedParticle(ByteBuf buffer){ Minecraft minecraft = Minecraft.getMinecraft(); diff --git a/src/main/java/noppes/npcs/client/PacketHandlerClient.java b/src/main/java/noppes/npcs/client/PacketHandlerClient.java index 0493ab8bf..d9921ea53 100644 --- a/src/main/java/noppes/npcs/client/PacketHandlerClient.java +++ b/src/main/java/noppes/npcs/client/PacketHandlerClient.java @@ -16,7 +16,6 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.network.PacketBuffer; import net.minecraft.stats.Achievement; import net.minecraft.util.ChatComponentTranslation; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraft.village.MerchantRecipeList; import noppes.npcs.CustomNpcs; @@ -274,11 +273,8 @@ public class PacketHandlerClient extends PacketHandlerServer{ else if(type == EnumPacketClient.SWING_PLAYER_ARM){ Minecraft.getMinecraft().thePlayer.swingItem(); } - else if(type == EnumPacketClient.PLAYER_OVERLAY) { - String overlayString = Server.readString(buffer); - if (overlayString != null) { - Client.playerOverlay = new ResourceLocation(overlayString); - } + else if(type == EnumPacketClient.CLIENT_UPDATE_SKIN_OVERLAYS) { + NoppesUtil.updateSkinOverlayData(player, Server.readNBT(buffer)); } } } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index 199dd3a85..082f97daf 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -3,54 +3,76 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; import noppes.npcs.client.Client; +import noppes.npcs.client.NoppesUtil; +import noppes.npcs.constants.EnumPacketServer; +import noppes.npcs.controllers.data.SkinOverlayData; import org.lwjgl.opengl.GL11; +import java.util.HashMap; + public class RenderCNPCPlayer extends RenderPlayer { public RenderCNPCPlayer() { } + private boolean preRenderOverlay(EntityPlayer player, ResourceLocation overlayLocation) { + try { + this.bindTexture(overlayLocation); + } catch (Exception exception) { + return false; + } + // Overlay & Glow + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + GL11.glDisable(GL11.GL_LIGHTING); + + GL11.glDepthMask(!player.isInvisible()); + + GL11.glPushMatrix(); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glScalef(1.0F, 1.0F, 1.0F); + + GL11.glMatrixMode(GL11.GL_MODELVIEW); + float scale = 1.001f; + GL11.glScalef(scale, scale, scale); + + return true; + } + public void postRenderOverlay(EntityPlayer player) { + GL11.glPopMatrix(); + + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glDisable(GL11.GL_BLEND); + } + @Override protected void renderModel(EntityLivingBase p_77036_1_, float p_77036_2_, float p_77036_3_, float p_77036_4_, float p_77036_5_, float p_77036_6_, float p_77036_7_) { + EntityPlayer player = (EntityPlayer) p_77036_1_; this.bindEntityTexture(p_77036_1_); if (!p_77036_1_.isInvisible()) { this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); - if (Client.playerOverlay != null) { - try { - this.bindTexture(Client.playerOverlay); - float f1 = 1.0F; - // Overlay & Glow - GL11.glDepthFunc(GL11.GL_LEQUAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); - GL11.glDisable(GL11.GL_LIGHTING); - - GL11.glDepthMask(!p_77036_1_.isInvisible()); - - GL11.glPushMatrix(); - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glLoadIdentity(); - GL11.glScalef(1.0F, 1.0F, 1.0F); - - GL11.glMatrixMode(GL11.GL_MODELVIEW); - float scale = 1.001f; - GL11.glScalef(scale, scale, scale); + if (Client.skinOverlays.containsKey(player.getUniqueID())) { + for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { + if (!preRenderOverlay(player, overlayData.location)) + return; this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); - GL11.glPopMatrix(); - - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glLoadIdentity(); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glColor4f(1.0F, 1.0F, 1.0F, f1); - GL11.glDepthFunc(GL11.GL_LEQUAL); - GL11.glDisable(GL11.GL_BLEND); - } catch (Exception ignored) {} + postRenderOverlay(player); + } + } else if(player.getEntityData().hasKey("SkinOverlayData")) { + Client.sendData(EnumPacketServer.SERVER_UPDATE_SKIN_OVERLAYS, new Object[0]); } } else if (!p_77036_1_.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) @@ -73,49 +95,26 @@ public class RenderCNPCPlayer extends RenderPlayer { } } - public void renderFirstPersonArm(EntityPlayer p_82441_1_) + public void renderFirstPersonArm(EntityPlayer player) { float f = 1.0F; GL11.glColor3f(f, f, f); this.modelBipedMain.onGround = 0.0F; - this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, p_82441_1_); + this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, player); this.modelBipedMain.bipedRightArm.render(0.0625F); - if (Client.playerOverlay != null) { - try { - this.bindTexture(Client.playerOverlay); - float f1 = 1.0F; - // Overlay & Glow - GL11.glDepthFunc(GL11.GL_LEQUAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); - GL11.glDisable(GL11.GL_LIGHTING); - - GL11.glDepthMask(!p_82441_1_.isInvisible()); - - GL11.glPushMatrix(); - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glLoadIdentity(); - GL11.glScalef(1.0F, 1.0F, 1.0F); - - GL11.glMatrixMode(GL11.GL_MODELVIEW); - float scale = 1.001f; - GL11.glScalef(scale, scale, scale); + if (Client.skinOverlays.containsKey(player.getUniqueID())) { + for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { + if (!preRenderOverlay(player, overlayData.location)) + return; GL11.glColor3f(1.0F, 1.0F, 1.0F); this.modelBipedMain.onGround = 0.0F; - this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, p_82441_1_); + this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, player); this.modelBipedMain.bipedRightArm.render(0.0625F); - GL11.glPopMatrix(); - - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glLoadIdentity(); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glColor4f(1.0F, 1.0F, 1.0F, f1); - GL11.glDepthFunc(GL11.GL_LEQUAL); - GL11.glDisable(GL11.GL_BLEND); - } catch (Exception ignored) {} + postRenderOverlay(player); + } + } else if(player.getEntityData().hasKey("SkinOverlayData")) { + Client.sendData(EnumPacketServer.SERVER_UPDATE_SKIN_OVERLAYS, new Object[0]); } } } diff --git a/src/main/java/noppes/npcs/constants/EnumPacketClient.java b/src/main/java/noppes/npcs/constants/EnumPacketClient.java index d3c312f7b..044959ccc 100644 --- a/src/main/java/noppes/npcs/constants/EnumPacketClient.java +++ b/src/main/java/noppes/npcs/constants/EnumPacketClient.java @@ -38,5 +38,5 @@ public enum EnumPacketClient { OVERLAY_CLOSE, SWING_PLAYER_ARM, UPDATE_ITEM, - PLAYER_OVERLAY + CLIENT_UPDATE_SKIN_OVERLAYS } diff --git a/src/main/java/noppes/npcs/constants/EnumPacketServer.java b/src/main/java/noppes/npcs/constants/EnumPacketServer.java index d84364ca0..d33490c9d 100644 --- a/src/main/java/noppes/npcs/constants/EnumPacketServer.java +++ b/src/main/java/noppes/npcs/constants/EnumPacketServer.java @@ -87,7 +87,9 @@ public enum EnumPacketServer { NaturalSpawnGetAll, MailOpenSetup, DimensionsGet, DimensionTeleport, GetTileEntity, Gui, IsGuiOpen, - CustomGuiButton,CustomGuiSlotChange,CustomGuiScrollClick,CustomGuiClose,CustomGuiUnfocused; + CustomGuiButton,CustomGuiSlotChange,CustomGuiScrollClick,CustomGuiClose,CustomGuiUnfocused, + + SERVER_UPDATE_SKIN_OVERLAYS; public CustomNpcsPermissions.Permission permission = null; public boolean needsNpc = false; diff --git a/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java b/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java new file mode 100644 index 000000000..726e17b5e --- /dev/null +++ b/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java @@ -0,0 +1,11 @@ +package noppes.npcs.controllers.data; + +import net.minecraft.util.ResourceLocation; + +public class SkinOverlayData { + public ResourceLocation location; + + public SkinOverlayData(ResourceLocation location) { + this.location = location; + } +} diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index a79d3c204..15360a73b 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -5,6 +5,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.stats.Achievement; import net.minecraft.stats.StatBase; import net.minecraft.stats.StatList; @@ -526,8 +527,44 @@ public class ScriptPlayer extends ScriptLivingBase Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.OVERLAY_CLOSE, id, new NBTTagCompound()); } - public void setPlayerOverlay(String texture) { - Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.PLAYER_OVERLAY, texture); + public void addSkinOverlay(int id, String overlayString) { + if (overlayString != null) { + NBTTagCompound data = new NBTTagCompound(); + NBTTagCompound compound = new NBTTagCompound(); + + compound.setString("SkinOverlayTexture", overlayString); + compound.setInteger("SkinOverlayID", id); + + if (!player.getEntityData().hasKey("SkinOverlayData")) { + NBTTagList tagList = new NBTTagList(); + tagList.appendTag(compound); + player.getEntityData().setTag("SkinOverlayData", tagList); + } else { + for (int i = 0; i < player.getEntityData().getTagList("SkinOverlayData", 10).tagCount(); i++) { + int tagID = player.getEntityData().getTagList("SkinOverlayData", 10).getCompoundTagAt(i).getInteger("SkinOverlayID"); + if (tagID == id) { + player.getEntityData().getTagList("SkinOverlayData", 10).removeTag(i); + } + } + player.getEntityData().getTagList("SkinOverlayData", 10).appendTag(compound); + } + data.setTag("SkinOverlayData",player.getEntityData().getTagList("SkinOverlayData",10)); + Server.sendData((EntityPlayerMP) this.entity, EnumPacketClient.CLIENT_UPDATE_SKIN_OVERLAYS, data); + } + } + + public void removeSkinOverlay(int id) { + if (player.getEntityData().hasKey("SkinOverlayData")) { + NBTTagCompound data = new NBTTagCompound(); + for (int i = 0; i < player.getEntityData().getTagList("SkinOverlayData",10).tagCount(); i++) { + int tagID = player.getEntityData().getTagList("SkinOverlayData",10).getCompoundTagAt(i).getInteger("SkinOverlayID"); + if (tagID == id) { + player.getEntityData().getTagList("SkinOverlayData",10).removeTag(i); + } + } + data.setTag("SkinOverlayData",player.getEntityData().getTagList("SkinOverlayData",10)); + Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.CLIENT_UPDATE_SKIN_OVERLAYS, data); + } } public IQuest[] getFinishedQuests() { From 6f9358c1caa4ba575e325858669391256daedbbc Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Mon, 16 May 2022 22:04:54 -0500 Subject: [PATCH 48/75] Glow can be disabled/enabled on skin overlays --- .../java/noppes/npcs/client/NoppesUtil.java | 3 ++- .../client/renderer/RenderCNPCPlayer.java | 25 ++++++++++-------- .../client/renderer/RenderNPCInterface.java | 4 +++ .../controllers/data/SkinOverlayData.java | 4 ++- .../java/noppes/npcs/scripted/NpcAPI.java | 16 +++++++++--- .../npcs/scripted/ScriptSkinOverlay.java | 26 +++++++++++++++++++ .../npcs/scripted/entity/ScriptPlayer.java | 7 ++--- .../scripted/interfaces/AbstractNpcAPI.java | 15 +++++++++++ .../scripted/interfaces/ISkinOverlay.java | 11 ++++++++ 9 files changed, 91 insertions(+), 20 deletions(-) create mode 100644 src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java create mode 100644 src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index 253293b48..b23104d27 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -79,8 +79,9 @@ public class NoppesUtil { for (int i = 0; i < skinOverlayList.tagCount(); i++) { int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID"); String tagString = skinOverlayList.getCompoundTagAt(i).getString("SkinOverlayTexture"); + boolean glow = skinOverlayList.getCompoundTagAt(i).getBoolean("SkinOverlayGlow"); - skinOverlays.put(tagID,new SkinOverlayData(new ResourceLocation(tagString))); + skinOverlays.put(tagID,new SkinOverlayData(new ResourceLocation(tagString),glow)); } Client.skinOverlays.put(player.getUniqueID(), skinOverlays); } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index 082f97daf..e17b7ffe7 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -1,33 +1,34 @@ package noppes.npcs.client.renderer; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import noppes.npcs.client.Client; -import noppes.npcs.client.NoppesUtil; import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.controllers.data.SkinOverlayData; import org.lwjgl.opengl.GL11; -import java.util.HashMap; - public class RenderCNPCPlayer extends RenderPlayer { public RenderCNPCPlayer() { } - private boolean preRenderOverlay(EntityPlayer player, ResourceLocation overlayLocation) { + private boolean preRenderOverlay(EntityPlayer player, ResourceLocation overlayLocation, boolean glow) { try { this.bindTexture(overlayLocation); } catch (Exception exception) { return false; } // Overlay & Glow - GL11.glDepthFunc(GL11.GL_LEQUAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); - GL11.glDisable(GL11.GL_LIGHTING); + if (glow) { + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); + Minecraft.getMinecraft().entityRenderer.disableLightmap((double)0); + } GL11.glDepthMask(!player.isInvisible()); @@ -37,7 +38,7 @@ public class RenderCNPCPlayer extends RenderPlayer { GL11.glScalef(1.0F, 1.0F, 1.0F); GL11.glMatrixMode(GL11.GL_MODELVIEW); - float scale = 1.001f; + float scale = 1.005f; GL11.glScalef(scale, scale, scale); return true; @@ -49,10 +50,12 @@ public class RenderCNPCPlayer extends RenderPlayer { GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glEnable(GL11.GL_LIGHTING); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDisable(GL11.GL_BLEND); + Minecraft.getMinecraft().entityRenderer.enableLightmap((double)0); } @Override @@ -66,7 +69,7 @@ public class RenderCNPCPlayer extends RenderPlayer { if (Client.skinOverlays.containsKey(player.getUniqueID())) { for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { - if (!preRenderOverlay(player, overlayData.location)) + if (!preRenderOverlay(player, overlayData.location, overlayData.glow)) return; this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); postRenderOverlay(player); @@ -105,7 +108,7 @@ public class RenderCNPCPlayer extends RenderPlayer { if (Client.skinOverlays.containsKey(player.getUniqueID())) { for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { - if (!preRenderOverlay(player, overlayData.location)) + if (!preRenderOverlay(player, overlayData.location, overlayData.glow)) return; GL11.glColor3f(1.0F, 1.0F, 1.0F); this.modelBipedMain.onGround = 0.0F; diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index 68bc2bb17..01deba024 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -230,6 +230,7 @@ public class RenderNPCInterface extends RenderLiving{ GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); GL11.glDisable(GL11.GL_LIGHTING); + Minecraft.getMinecraft().entityRenderer.disableLightmap((double)0); GL11.glDepthMask(!npc.isInvisible()); GL11.glColor4f(1.0F, 1.0F, 1.0F, npc.isInvisible() ? 0.2F : 1.0F); @@ -259,6 +260,7 @@ public class RenderNPCInterface extends RenderLiving{ GL11.glColor4f(1.0F, 1.0F, 1.0F, f1); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDisable(GL11.GL_BLEND); + Minecraft.getMinecraft().entityRenderer.enableLightmap((double)0); } if (!npc.display.poweredTexture.isEmpty() && !npc.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) @@ -280,6 +282,7 @@ public class RenderNPCInterface extends RenderLiving{ GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); GL11.glDisable(GL11.GL_LIGHTING); + Minecraft.getMinecraft().entityRenderer.disableLightmap((double)0); GL11.glDepthMask(!npc.isInvisible()); GL11.glColor4f(1.0F, 1.0F, 1.0F, npc.isInvisible() ? 0.2F : 1.0F); @@ -311,6 +314,7 @@ public class RenderNPCInterface extends RenderLiving{ GL11.glColor4f(1.0F, 1.0F, 1.0F, f1); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDisable(GL11.GL_BLEND); + Minecraft.getMinecraft().entityRenderer.enableLightmap((double)0); npc.renderTicksPowered++; } diff --git a/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java b/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java index 726e17b5e..20e5207bf 100644 --- a/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java +++ b/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java @@ -4,8 +4,10 @@ import net.minecraft.util.ResourceLocation; public class SkinOverlayData { public ResourceLocation location; + public boolean glow; - public SkinOverlayData(ResourceLocation location) { + public SkinOverlayData(ResourceLocation location, boolean glow) { this.location = location; + this.glow = glow; } } diff --git a/src/main/java/noppes/npcs/scripted/NpcAPI.java b/src/main/java/noppes/npcs/scripted/NpcAPI.java index 35eff98b7..7b4ad5113 100644 --- a/src/main/java/noppes/npcs/scripted/NpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/NpcAPI.java @@ -316,16 +316,14 @@ public class NpcAPI extends AbstractNpcAPI { return MinecraftServer.getServer().getTickCounter(); } - public ICustomGui createCustomGui(int id, int width, int height, boolean pauseGame) { - return new ScriptGui(id, width, height, pauseGame); - } - public boolean arePlayerScriptsEnabled() { return CustomNpcs.GlobalPlayerScripts; } + public boolean areForgeScriptsEnabled() { return CustomNpcs.GlobalForgeScripts; } + public boolean areGlobalNPCScriptsEnabled() { return CustomNpcs.GlobalNPCScripts; } @@ -333,14 +331,24 @@ public class NpcAPI extends AbstractNpcAPI { public void enablePlayerScripts(boolean enable) { CustomNpcs.GlobalPlayerScripts = enable; } + public void enableForgeScripts(boolean enable) { CustomNpcs.GlobalForgeScripts = enable; } + public void enableGlobalNPCScripts(boolean enable) { CustomNpcs.GlobalNPCScripts = enable; } + public ICustomGui createCustomGui(int id, int width, int height, boolean pauseGame) { + return new ScriptGui(id, width, height, pauseGame); + } + public ICustomOverlay createCustomOverlay(int id) { return new ScriptOverlay(id); } + + public ISkinOverlay createSkinOverlay(String texture) { + return new ScriptSkinOverlay(texture); + } } diff --git a/src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java b/src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java new file mode 100644 index 000000000..b18d06be8 --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java @@ -0,0 +1,26 @@ +package noppes.npcs.scripted; + +import noppes.npcs.scripted.interfaces.ISkinOverlay; + +public class ScriptSkinOverlay implements ISkinOverlay { + public String texture; + public boolean glow; + + public ScriptSkinOverlay(String texture) { + this.texture = texture; + } + + public void setTexture(String texture) { + this.texture = texture; + } + public String getTexture() { + return texture; + } + + public void setGlow(boolean glow) { + this.glow = glow; + } + public boolean getGlow() { + return glow; + } +} diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index 15360a73b..9377732c9 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -527,13 +527,14 @@ public class ScriptPlayer extends ScriptLivingBase Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.OVERLAY_CLOSE, id, new NBTTagCompound()); } - public void addSkinOverlay(int id, String overlayString) { - if (overlayString != null) { + public void setSkinOverlay(int id, ScriptSkinOverlay overlay) { + if (overlay != null) { NBTTagCompound data = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound(); - compound.setString("SkinOverlayTexture", overlayString); compound.setInteger("SkinOverlayID", id); + compound.setString("SkinOverlayTexture", overlay.getTexture()); + compound.setBoolean("SkinOverlayGlow", overlay.getGlow()); if (!player.getEntityData().hasKey("SkinOverlayData")) { NBTTagList tagList = new NBTTagList(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/AbstractNpcAPI.java b/src/main/java/noppes/npcs/scripted/interfaces/AbstractNpcAPI.java index 013405db4..611848222 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/AbstractNpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/AbstractNpcAPI.java @@ -20,6 +20,7 @@ import net.minecraft.util.DamageSource; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.WorldServer; +import noppes.npcs.CustomNpcs; import noppes.npcs.controllers.*; import noppes.npcs.scripted.gui.ScriptGui; import noppes.npcs.scripted.interfaces.entity.ICustomNpc; @@ -122,7 +123,21 @@ public abstract class AbstractNpcAPI { public abstract int getServerTime(); + public abstract boolean arePlayerScriptsEnabled(); + + public abstract boolean areForgeScriptsEnabled(); + + public abstract boolean areGlobalNPCScriptsEnabled(); + + public abstract void enablePlayerScripts(boolean enable); + + public abstract void enableForgeScripts(boolean enable); + + public abstract void enableGlobalNPCScripts(boolean enable); + public abstract ICustomGui createCustomGui(int id, int width, int height, boolean pauseGame); public abstract ICustomOverlay createCustomOverlay(int id); + + public abstract ISkinOverlay createSkinOverlay(String texture); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java b/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java new file mode 100644 index 000000000..9ea1d1886 --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java @@ -0,0 +1,11 @@ +package noppes.npcs.scripted.interfaces; + +public interface ISkinOverlay { + void setTexture(String texture); + + String getTexture(); + + void setGlow(boolean glow); + + boolean getGlow(); +} From 83fbccdf55c3cbcdd6fe4bcbd8fac0025f86ec36 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Mon, 16 May 2022 22:14:11 -0500 Subject: [PATCH 49/75] Added setAlpha to skin overlays --- src/main/java/noppes/npcs/client/NoppesUtil.java | 3 ++- .../noppes/npcs/client/renderer/RenderCNPCPlayer.java | 10 +++++----- .../noppes/npcs/controllers/data/SkinOverlayData.java | 4 +++- .../java/noppes/npcs/scripted/ScriptSkinOverlay.java | 8 ++++++++ .../java/noppes/npcs/scripted/entity/ScriptPlayer.java | 1 + 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index b23104d27..3e22578a3 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -80,8 +80,9 @@ public class NoppesUtil { int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID"); String tagString = skinOverlayList.getCompoundTagAt(i).getString("SkinOverlayTexture"); boolean glow = skinOverlayList.getCompoundTagAt(i).getBoolean("SkinOverlayGlow"); + float alpha = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayAlpha"); - skinOverlays.put(tagID,new SkinOverlayData(new ResourceLocation(tagString),glow)); + skinOverlays.put(tagID,new SkinOverlayData(new ResourceLocation(tagString),glow,alpha)); } Client.skinOverlays.put(player.getUniqueID(), skinOverlays); } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index e17b7ffe7..ed0cd10f6 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -15,7 +15,7 @@ public class RenderCNPCPlayer extends RenderPlayer { public RenderCNPCPlayer() { } - private boolean preRenderOverlay(EntityPlayer player, ResourceLocation overlayLocation, boolean glow) { + private boolean preRenderOverlay(EntityPlayer player, ResourceLocation overlayLocation, boolean glow, float alpha) { try { this.bindTexture(overlayLocation); } catch (Exception exception) { @@ -30,6 +30,8 @@ public class RenderCNPCPlayer extends RenderPlayer { Minecraft.getMinecraft().entityRenderer.disableLightmap((double)0); } + GL11.glColor4f(1.0F, 1.0F, 1.0F, alpha); + GL11.glDepthMask(!player.isInvisible()); GL11.glPushMatrix(); @@ -50,7 +52,6 @@ public class RenderCNPCPlayer extends RenderPlayer { GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glEnable(GL11.GL_LIGHTING); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDepthFunc(GL11.GL_LEQUAL); @@ -69,7 +70,7 @@ public class RenderCNPCPlayer extends RenderPlayer { if (Client.skinOverlays.containsKey(player.getUniqueID())) { for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { - if (!preRenderOverlay(player, overlayData.location, overlayData.glow)) + if (!preRenderOverlay(player, overlayData.location, overlayData.glow, overlayData.alpha)) return; this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); postRenderOverlay(player); @@ -108,9 +109,8 @@ public class RenderCNPCPlayer extends RenderPlayer { if (Client.skinOverlays.containsKey(player.getUniqueID())) { for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { - if (!preRenderOverlay(player, overlayData.location, overlayData.glow)) + if (!preRenderOverlay(player, overlayData.location, overlayData.glow, overlayData.alpha)) return; - GL11.glColor3f(1.0F, 1.0F, 1.0F); this.modelBipedMain.onGround = 0.0F; this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, player); this.modelBipedMain.bipedRightArm.render(0.0625F); diff --git a/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java b/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java index 20e5207bf..21fbe6b88 100644 --- a/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java +++ b/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java @@ -5,9 +5,11 @@ import net.minecraft.util.ResourceLocation; public class SkinOverlayData { public ResourceLocation location; public boolean glow; + public float alpha = 1.0F; - public SkinOverlayData(ResourceLocation location, boolean glow) { + public SkinOverlayData(ResourceLocation location, boolean glow, float alpha) { this.location = location; this.glow = glow; + this.alpha = alpha; } } diff --git a/src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java b/src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java index b18d06be8..bd45ad216 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java +++ b/src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java @@ -5,6 +5,7 @@ import noppes.npcs.scripted.interfaces.ISkinOverlay; public class ScriptSkinOverlay implements ISkinOverlay { public String texture; public boolean glow; + public float alpha = 1.0F; public ScriptSkinOverlay(String texture) { this.texture = texture; @@ -23,4 +24,11 @@ public class ScriptSkinOverlay implements ISkinOverlay { public boolean getGlow() { return glow; } + + public void setAlpha(float alpha) { + this.alpha = alpha; + } + public float getAlpha() { + return alpha; + } } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index 9377732c9..65d243adf 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -535,6 +535,7 @@ public class ScriptPlayer extends ScriptLivingBase compound.setInteger("SkinOverlayID", id); compound.setString("SkinOverlayTexture", overlay.getTexture()); compound.setBoolean("SkinOverlayGlow", overlay.getGlow()); + compound.setFloat("SkinOverlayAlpha", overlay.getAlpha()); if (!player.getEntityData().hasKey("SkinOverlayData")) { NBTTagList tagList = new NBTTagList(); From f9fcd6b9f8b5fc16721763fca5d66893d29557ea Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Mon, 16 May 2022 23:27:11 -0500 Subject: [PATCH 50/75] Added alpha, size, scale, and speed attributes to player skin overlays. --- src/main/java/noppes/npcs/client/Client.java | 3 ++ .../java/noppes/npcs/client/NoppesUtil.java | 7 +++- .../client/renderer/RenderCNPCPlayer.java | 34 +++++++++++++---- .../controllers/data/SkinOverlayData.java | 14 ++++++- .../npcs/scripted/ScriptSkinOverlay.java | 37 +++++++++++++++++++ .../npcs/scripted/entity/ScriptPlayer.java | 5 +++ .../scripted/interfaces/ISkinOverlay.java | 14 +++++++ 7 files changed, 105 insertions(+), 9 deletions(-) diff --git a/src/main/java/noppes/npcs/client/Client.java b/src/main/java/noppes/npcs/client/Client.java index 0e801c6b9..48451bb6c 100644 --- a/src/main/java/noppes/npcs/client/Client.java +++ b/src/main/java/noppes/npcs/client/Client.java @@ -17,7 +17,10 @@ import noppes.npcs.controllers.data.SkinOverlayData; public class Client { public static HashMap customOverlays = new HashMap<>(); + public static HashMap> skinOverlays = new HashMap<>(); + public static HashMap fpSkinOverlayTicks = new HashMap<>(); + public static HashMap entitySkinOverlayTicks = new HashMap<>(); public static void sendData(EnumPacketServer enu, Object... obs) { ByteBuf buffer = Unpooled.buffer(); diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index 3e22578a3..094ec7d7f 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -81,8 +81,13 @@ public class NoppesUtil { String tagString = skinOverlayList.getCompoundTagAt(i).getString("SkinOverlayTexture"); boolean glow = skinOverlayList.getCompoundTagAt(i).getBoolean("SkinOverlayGlow"); float alpha = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayAlpha"); + float size = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySize"); + float speedX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySpeedX"); + float speedY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySpeedY"); + float scaleX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayScaleX"); + float scaleY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayScaleY"); - skinOverlays.put(tagID,new SkinOverlayData(new ResourceLocation(tagString),glow,alpha)); + skinOverlays.put(tagID,new SkinOverlayData(new ResourceLocation(tagString),glow,alpha,size,speedX,speedY,scaleX,scaleY)); } Client.skinOverlays.put(player.getUniqueID(), skinOverlays); } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index ed0cd10f6..81c8342e4 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -1,6 +1,6 @@ package noppes.npcs.client.renderer; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -11,16 +11,23 @@ import noppes.npcs.controllers.data.SkinOverlayData; import org.lwjgl.opengl.GL11; public class RenderCNPCPlayer extends RenderPlayer { - public RenderCNPCPlayer() { } - private boolean preRenderOverlay(EntityPlayer player, ResourceLocation overlayLocation, boolean glow, float alpha) { + private boolean preRenderOverlay(boolean firstPerson, EntityPlayer player, ResourceLocation overlayLocation, boolean glow, float alpha, float size, float speedX, float speedY, float scaleX, float scaleY) { try { this.bindTexture(overlayLocation); } catch (Exception exception) { return false; } + + float renderTicks; + if (firstPerson) { + renderTicks = Client.fpSkinOverlayTicks.get(player.getUniqueID()); + } else { + renderTicks = Client.entitySkinOverlayTicks.get(player.getUniqueID());; + } + // Overlay & Glow if (glow) { GL11.glDepthFunc(GL11.GL_LEQUAL); @@ -37,10 +44,11 @@ public class RenderCNPCPlayer extends RenderPlayer { GL11.glPushMatrix(); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); - GL11.glScalef(1.0F, 1.0F, 1.0F); + GL11.glTranslatef(renderTicks * 0.001F * speedX, renderTicks * 0.001F * speedY, 0.0F); + GL11.glScalef(scaleX, scaleY, 1.0F); GL11.glMatrixMode(GL11.GL_MODELVIEW); - float scale = 1.005f; + float scale = 1.005f * size; GL11.glScalef(scale, scale, scale); return true; @@ -69,8 +77,14 @@ public class RenderCNPCPlayer extends RenderPlayer { this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); if (Client.skinOverlays.containsKey(player.getUniqueID())) { + if (!Client.entitySkinOverlayTicks.containsKey(player.getUniqueID())) { + Client.entitySkinOverlayTicks.put(player.getUniqueID(), 1L); + } else { + long ticks = Client.entitySkinOverlayTicks.get(player.getUniqueID()); + Client.entitySkinOverlayTicks.put(player.getUniqueID(), ticks + 1); + } for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { - if (!preRenderOverlay(player, overlayData.location, overlayData.glow, overlayData.alpha)) + if (!preRenderOverlay(false, player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size, overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY)) return; this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); postRenderOverlay(player); @@ -108,8 +122,14 @@ public class RenderCNPCPlayer extends RenderPlayer { this.modelBipedMain.bipedRightArm.render(0.0625F); if (Client.skinOverlays.containsKey(player.getUniqueID())) { + if (!Client.fpSkinOverlayTicks.containsKey(player.getUniqueID())) { + Client.fpSkinOverlayTicks.put(player.getUniqueID(), 1L); + } else { + long ticks = Client.fpSkinOverlayTicks.get(player.getUniqueID()); + Client.fpSkinOverlayTicks.put(player.getUniqueID(), ticks + 1); + } for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { - if (!preRenderOverlay(player, overlayData.location, overlayData.glow, overlayData.alpha)) + if (!preRenderOverlay(true, player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size, overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY)) return; this.modelBipedMain.onGround = 0.0F; this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, player); diff --git a/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java b/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java index 21fbe6b88..7d8873bc3 100644 --- a/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java +++ b/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java @@ -6,10 +6,22 @@ public class SkinOverlayData { public ResourceLocation location; public boolean glow; public float alpha = 1.0F; + public float size = 1.0F; - public SkinOverlayData(ResourceLocation location, boolean glow, float alpha) { + public float speedX = 0.0F; + public float speedY = 0.0F; + + public float scaleX = 1.0F; + public float scaleY = 1.0F; + + public SkinOverlayData(ResourceLocation location, boolean glow, float alpha, float size, float speedX, float speedY, float scaleX, float scaleY) { this.location = location; this.glow = glow; this.alpha = alpha; + this.size = size; + this.speedX = speedX; + this.speedY = speedY; + this.scaleX = scaleX; + this.scaleY = scaleY; } } diff --git a/src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java b/src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java index bd45ad216..48de9516b 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java +++ b/src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java @@ -6,6 +6,13 @@ public class ScriptSkinOverlay implements ISkinOverlay { public String texture; public boolean glow; public float alpha = 1.0F; + public float size = 1.0F; + + public float speedX = 0.0F; + public float speedY = 0.0F; + + public float scaleX = 1.0F; + public float scaleY = 1.0F; public ScriptSkinOverlay(String texture) { this.texture = texture; @@ -31,4 +38,34 @@ public class ScriptSkinOverlay implements ISkinOverlay { public float getAlpha() { return alpha; } + + public void setSize(float size) { + this.size = size; + } + public float getSize() { + return size; + } + + public void setScale(float scaleX, float scaleY) { + this.scaleX = scaleX; + this.scaleY = scaleY; + } + public float getScaleX() { + return scaleX; + } + public float getScaleY() { + return scaleY; + } + + public void setSpeed(float speedX, float speedY) { + this.speedX = speedX; + this.speedY = speedY; + } + public float getSpeedX() { + return speedX; + } + public float getSpeedY() { + return speedY; + } + } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index 65d243adf..ed8cc7b16 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -536,6 +536,11 @@ public class ScriptPlayer extends ScriptLivingBase compound.setString("SkinOverlayTexture", overlay.getTexture()); compound.setBoolean("SkinOverlayGlow", overlay.getGlow()); compound.setFloat("SkinOverlayAlpha", overlay.getAlpha()); + compound.setFloat("SkinOverlaySize", overlay.getSize()); + compound.setFloat("SkinOverlaySpeedX", overlay.getSpeedX()); + compound.setFloat("SkinOverlaySpeedY", overlay.getSpeedY()); + compound.setFloat("SkinOverlayScaleX", overlay.getScaleX()); + compound.setFloat("SkinOverlayScaleY", overlay.getScaleY()); if (!player.getEntityData().hasKey("SkinOverlayData")) { NBTTagList tagList = new NBTTagList(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java b/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java index 9ea1d1886..b3ef3d442 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java @@ -8,4 +8,18 @@ public interface ISkinOverlay { void setGlow(boolean glow); boolean getGlow(); + + void setAlpha(float alpha); + float getAlpha(); + + void setSize(float size); + float getSize(); + + void setScale(float scaleX, float scaleY); + float getScaleX(); + float getScaleY(); + + void setSpeed(float speedX, float speedY); + float getSpeedX(); + float getSpeedY(); } From e8a3eb834412af88ccb28bb6560b1c2a2796391f Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 17 May 2022 00:01:31 -0500 Subject: [PATCH 51/75] Implemented offsets for player skin overlays --- .../java/noppes/npcs/client/NoppesUtil.java | 5 ++- .../client/renderer/RenderCNPCPlayer.java | 39 ++++++++++++------- .../controllers/data/SkinOverlayData.java | 10 ++++- .../npcs/scripted/ScriptSkinOverlay.java | 18 +++++++++ .../npcs/scripted/entity/ScriptPlayer.java | 3 ++ .../scripted/interfaces/ISkinOverlay.java | 5 +++ 6 files changed, 63 insertions(+), 17 deletions(-) diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index 094ec7d7f..c29fabf27 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -86,8 +86,11 @@ public class NoppesUtil { float speedY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySpeedY"); float scaleX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayScaleX"); float scaleY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayScaleY"); + float offsetX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetX"); + float offsetY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetY"); + float offsetZ = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetZ"); - skinOverlays.put(tagID,new SkinOverlayData(new ResourceLocation(tagString),glow,alpha,size,speedX,speedY,scaleX,scaleY)); + skinOverlays.put(tagID,new SkinOverlayData(new ResourceLocation(tagString),glow,alpha,size,speedX,speedY,scaleX,scaleY,offsetX,offsetY,offsetZ)); } Client.skinOverlays.put(player.getUniqueID(), skinOverlays); } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index 81c8342e4..d15e5df01 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -14,7 +14,9 @@ public class RenderCNPCPlayer extends RenderPlayer { public RenderCNPCPlayer() { } - private boolean preRenderOverlay(boolean firstPerson, EntityPlayer player, ResourceLocation overlayLocation, boolean glow, float alpha, float size, float speedX, float speedY, float scaleX, float scaleY) { + private boolean preRenderOverlay(boolean firstPerson, EntityPlayer player, ResourceLocation overlayLocation, boolean glow, + float alpha, float size, float speedX, float speedY, float scaleX, float scaleY, + float offsetX, float offsetY, float offsetZ) { try { this.bindTexture(overlayLocation); } catch (Exception exception) { @@ -23,8 +25,20 @@ public class RenderCNPCPlayer extends RenderPlayer { float renderTicks; if (firstPerson) { + if (!Client.fpSkinOverlayTicks.containsKey(player.getUniqueID())) { + Client.fpSkinOverlayTicks.put(player.getUniqueID(), 1L); + } else { + long ticks = Client.fpSkinOverlayTicks.get(player.getUniqueID()); + Client.fpSkinOverlayTicks.put(player.getUniqueID(), ticks + 1); + } renderTicks = Client.fpSkinOverlayTicks.get(player.getUniqueID()); } else { + if (!Client.entitySkinOverlayTicks.containsKey(player.getUniqueID())) { + Client.entitySkinOverlayTicks.put(player.getUniqueID(), 1L); + } else { + long ticks = Client.entitySkinOverlayTicks.get(player.getUniqueID()); + Client.entitySkinOverlayTicks.put(player.getUniqueID(), ticks + 1); + } renderTicks = Client.entitySkinOverlayTicks.get(player.getUniqueID());; } @@ -49,6 +63,7 @@ public class RenderCNPCPlayer extends RenderPlayer { GL11.glMatrixMode(GL11.GL_MODELVIEW); float scale = 1.005f * size; + GL11.glTranslatef(offsetX, offsetY, offsetZ); GL11.glScalef(scale, scale, scale); return true; @@ -77,14 +92,11 @@ public class RenderCNPCPlayer extends RenderPlayer { this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); if (Client.skinOverlays.containsKey(player.getUniqueID())) { - if (!Client.entitySkinOverlayTicks.containsKey(player.getUniqueID())) { - Client.entitySkinOverlayTicks.put(player.getUniqueID(), 1L); - } else { - long ticks = Client.entitySkinOverlayTicks.get(player.getUniqueID()); - Client.entitySkinOverlayTicks.put(player.getUniqueID(), ticks + 1); - } for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { - if (!preRenderOverlay(false, player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size, overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY)) + if (!preRenderOverlay(false, player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size, + overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY, + overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ + )) return; this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); postRenderOverlay(player); @@ -122,14 +134,11 @@ public class RenderCNPCPlayer extends RenderPlayer { this.modelBipedMain.bipedRightArm.render(0.0625F); if (Client.skinOverlays.containsKey(player.getUniqueID())) { - if (!Client.fpSkinOverlayTicks.containsKey(player.getUniqueID())) { - Client.fpSkinOverlayTicks.put(player.getUniqueID(), 1L); - } else { - long ticks = Client.fpSkinOverlayTicks.get(player.getUniqueID()); - Client.fpSkinOverlayTicks.put(player.getUniqueID(), ticks + 1); - } for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { - if (!preRenderOverlay(true, player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size, overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY)) + if (!preRenderOverlay(false, player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size, + overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY, + overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ + )) return; this.modelBipedMain.onGround = 0.0F; this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, player); diff --git a/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java b/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java index 7d8873bc3..8b6f0bdc7 100644 --- a/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java +++ b/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java @@ -14,7 +14,12 @@ public class SkinOverlayData { public float scaleX = 1.0F; public float scaleY = 1.0F; - public SkinOverlayData(ResourceLocation location, boolean glow, float alpha, float size, float speedX, float speedY, float scaleX, float scaleY) { + public float offsetX = 0.0F; + public float offsetY = 0.0F; + public float offsetZ = 0.0F; + + public SkinOverlayData(ResourceLocation location, boolean glow, float alpha, float size, float speedX, float speedY, + float scaleX, float scaleY, float offsetX, float offsetY, float offsetZ) { this.location = location; this.glow = glow; this.alpha = alpha; @@ -23,5 +28,8 @@ public class SkinOverlayData { this.speedY = speedY; this.scaleX = scaleX; this.scaleY = scaleY; + this.offsetX = offsetX; + this.offsetY = offsetY; + this.offsetZ = offsetZ; } } diff --git a/src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java b/src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java index 48de9516b..40127d044 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java +++ b/src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java @@ -14,6 +14,10 @@ public class ScriptSkinOverlay implements ISkinOverlay { public float scaleX = 1.0F; public float scaleY = 1.0F; + public float offsetX = 0.0F; + public float offsetY = 0.0F; + public float offsetZ = 0.0F; + public ScriptSkinOverlay(String texture) { this.texture = texture; } @@ -68,4 +72,18 @@ public class ScriptSkinOverlay implements ISkinOverlay { return speedY; } + public void setOffset(float offsetX, float offsetY, float offsetZ) { + this.offsetX = offsetX; + this.offsetY = offsetY; + this.offsetZ = offsetZ; + } + public float getOffsetX() { + return offsetX; + } + public float getOffsetY() { + return offsetY; + } + public float getOffsetZ() { + return offsetZ; + } } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index ed8cc7b16..f787d8821 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -541,6 +541,9 @@ public class ScriptPlayer extends ScriptLivingBase compound.setFloat("SkinOverlaySpeedY", overlay.getSpeedY()); compound.setFloat("SkinOverlayScaleX", overlay.getScaleX()); compound.setFloat("SkinOverlayScaleY", overlay.getScaleY()); + compound.setFloat("SkinOverlayOffsetX", overlay.getOffsetX()); + compound.setFloat("SkinOverlayOffsetY", overlay.getOffsetY()); + compound.setFloat("SkinOverlayOffsetZ", overlay.getOffsetZ()); if (!player.getEntityData().hasKey("SkinOverlayData")) { NBTTagList tagList = new NBTTagList(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java b/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java index b3ef3d442..e516cbc8c 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java @@ -22,4 +22,9 @@ public interface ISkinOverlay { void setSpeed(float speedX, float speedY); float getSpeedX(); float getSpeedY(); + + void setOffset(float offsetX, float offsetY, float offsetZ); + float getOffsetX(); + float getOffsetY(); + float getOffsetZ(); } From 8bc3190295b3b489b922b3e0c6e57c9802b9fe0f Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 17 May 2022 04:34:46 -0500 Subject: [PATCH 52/75] Implemented multiple overlay layers for CNPCs, replaces powered textures. --- src/main/java/noppes/npcs/DataDisplay.java | 115 +++++++----- .../java/noppes/npcs/PacketHandlerServer.java | 2 +- .../noppes/npcs/ScriptPlayerEventHandler.java | 2 +- .../java/noppes/npcs/client/NoppesUtil.java | 5 +- .../npcs/client/PacketHandlerClient.java | 2 +- .../client/gui/GuiNpcTextureOverlays.java | 21 ++- .../client/gui/mainmenu/GuiNpcDisplay.java | 11 +- .../client/gui/model/GuiCreationScreen.java | 8 +- .../client/gui/model/GuiEntitySelection.java | 5 +- .../client/renderer/RenderCNPCPlayer.java | 18 ++ .../client/renderer/RenderNPCInterface.java | 165 +++++++----------- .../npcs/constants/EnumPacketClient.java | 2 +- .../controllers/data/SkinOverlayData.java | 7 +- .../npcs/entity/EntityNPCInterface.java | 2 - .../npcs/entity/old/EntityNPCEnderman.java | 8 +- .../npcs/scripted/entity/ScriptNpc.java | 57 +++--- .../npcs/scripted/entity/ScriptPlayer.java | 10 +- .../interfaces/entity/ICustomNpc.java | 4 - 18 files changed, 234 insertions(+), 210 deletions(-) diff --git a/src/main/java/noppes/npcs/DataDisplay.java b/src/main/java/noppes/npcs/DataDisplay.java index 5ce64cd92..befd353fc 100644 --- a/src/main/java/noppes/npcs/DataDisplay.java +++ b/src/main/java/noppes/npcs/DataDisplay.java @@ -1,9 +1,6 @@ package noppes.npcs; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.UUID; +import java.util.*; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayerMP; @@ -13,6 +10,8 @@ import net.minecraft.nbt.NBTTagString; import net.minecraft.nbt.NBTUtil; import net.minecraft.server.MinecraftServer; import net.minecraft.util.StringUtils; +import noppes.npcs.constants.EnumPacketClient; +import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.util.ValueUtil; @@ -37,17 +36,10 @@ public class DataDisplay { public String texture = "customnpcs:textures/entity/humanmale/Steve.png"; public String cloakTexture = ""; - public String glowTexture = ""; - public float overlaySize = 1.0F; - public float overlayScaleX = 1.0F; - public float overlayScaleY = 1.0F; + public HashMap skinOverlays = new HashMap<>(); + public long overlayRenderTicks = 0; - public String poweredTexture = ""; - public float poweredSize = 1.0F; - public float poweredSpeedX = 1.0F; - public float poweredSpeedY = 1.0F; - public float poweredScaleX = 1.0F; - public float poweredScaleY = 1.0F; + public String glowTexture = ""; public int visible = 0; //0:visible 1:Invisible 2:semi-invisible @@ -76,6 +68,30 @@ public class DataDisplay { return CustomNpcs.MARKOV_GENERATOR[markovGeneratorId].fetch(markovGender); } + public NBTTagCompound writeOverlaysToNBT(NBTTagCompound nbttagcompound) { + NBTTagList overlayList = new NBTTagList(); + if (!npc.display.skinOverlays.isEmpty()) { + for (Map.Entry overlayData : npc.display.skinOverlays.entrySet()) { + NBTTagCompound compound = new NBTTagCompound(); + compound.setInteger("SkinOverlayID", overlayData.getKey()); + compound.setString("SkinOverlayTexture", overlayData.getValue().directory); + compound.setBoolean("SkinOverlayGlow", overlayData.getValue().glow); + compound.setFloat("SkinOverlayAlpha", overlayData.getValue().alpha); + compound.setFloat("SkinOverlaySize", overlayData.getValue().size); + compound.setFloat("SkinOverlaySpeedX", overlayData.getValue().speedX); + compound.setFloat("SkinOverlaySpeedY", overlayData.getValue().speedY); + compound.setFloat("SkinOverlayScaleX", overlayData.getValue().scaleX); + compound.setFloat("SkinOverlayScaleY", overlayData.getValue().scaleY); + compound.setFloat("SkinOverlayOffsetX", overlayData.getValue().offsetX); + compound.setFloat("SkinOverlayOffsetY", overlayData.getValue().offsetY); + compound.setFloat("SkinOverlayOffsetZ", overlayData.getValue().offsetZ); + overlayList.appendTag(compound); + } + } + nbttagcompound.setTag("SkinOverlayData",overlayList); + return nbttagcompound; + } + public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { nbttagcompound.setString("Name", name); nbttagcompound.setInteger("MarkovGeneratorId", markovGeneratorId); @@ -85,18 +101,9 @@ public class DataDisplay { nbttagcompound.setString("Texture", texture); nbttagcompound.setString("CloakTexture", cloakTexture); nbttagcompound.setByte("UsingSkinUrl", skinType); - nbttagcompound.setString("GlowTexture", glowTexture); - nbttagcompound.setFloat("OverlaySize", overlaySize); - nbttagcompound.setFloat("OverlayScaleX", overlayScaleX); - nbttagcompound.setFloat("OverlayScaleY", overlayScaleY); - nbttagcompound.setString("PoweredTexture", poweredTexture); - nbttagcompound.setFloat("PoweredSize", poweredSize); - nbttagcompound.setFloat("PoweredSpeedX", poweredSpeedX); - nbttagcompound.setFloat("PoweredSpeedY", poweredSpeedY); - nbttagcompound.setFloat("PoweredScaleX", poweredScaleX); - nbttagcompound.setFloat("PoweredScaleY", poweredScaleY); + nbttagcompound = writeOverlaysToNBT(nbttagcompound); if (this.playerProfile != null) { @@ -152,26 +159,50 @@ public class DataDisplay { texture = nbttagcompound.getString("Texture"); cloakTexture = nbttagcompound.getString("CloakTexture"); - - overlayScaleX = overlayScaleX == 0 ? 1.0F : overlayScaleX; - overlayScaleY = overlayScaleY == 0 ? 1.0F : overlayScaleY; - overlaySize = overlaySize == 0 ? 1.0F : overlaySize; glowTexture = nbttagcompound.getString("GlowTexture"); - overlaySize = nbttagcompound.getFloat("OverlaySize"); - overlayScaleX = nbttagcompound.getFloat("OverlayScaleX"); - overlayScaleY = nbttagcompound.getFloat("OverlayScaleY"); - poweredScaleX = poweredScaleX == 0 ? 1.0F : poweredScaleX; - poweredScaleY = poweredScaleY == 0 ? 1.0F : poweredScaleY; - poweredSpeedX = poweredSpeedX == 0 ? 1.0F : poweredSpeedX; - poweredSpeedY = poweredSpeedY == 0 ? 1.0F : poweredSpeedY; - poweredSize = poweredSize == 0 ? 1.0F : poweredSize; - poweredTexture = nbttagcompound.getString("PoweredTexture"); - poweredSize = nbttagcompound.getFloat("PoweredSize"); - poweredSpeedX = nbttagcompound.getFloat("PoweredSpeedX"); - poweredSpeedY = nbttagcompound.getFloat("PoweredSpeedY"); - poweredScaleX = nbttagcompound.getFloat("PoweredScaleX"); - poweredScaleY = nbttagcompound.getFloat("PoweredScaleY"); + if (!nbttagcompound.hasKey("SkinOverlayData") && !glowTexture.isEmpty()) { + NBTTagCompound compound = new NBTTagCompound(); + compound.setInteger("SkinOverlayID", 0); //unique glow texture ID + compound.setString("SkinOverlayTexture", glowTexture); + compound.setBoolean("SkinOverlayGlow", true); + compound.setFloat("SkinOverlayAlpha", 1.0F); + compound.setFloat("SkinOverlaySize", 1.0F); + compound.setFloat("SkinOverlaySpeedX", 0.0F); + compound.setFloat("SkinOverlaySpeedY", 0.0F); + compound.setFloat("SkinOverlayScaleX", 1.0F); + compound.setFloat("SkinOverlayScaleY", 1.0F); + compound.setFloat("SkinOverlayOffsetX", 0.0F); + compound.setFloat("SkinOverlayOffsetY", 0.0F); + compound.setFloat("SkinOverlayOffsetZ", 0.0F); + + if (!nbttagcompound.hasKey("SkinOverlayData")) { + NBTTagList tagList = new NBTTagList(); + tagList.appendTag(compound); + nbttagcompound.setTag("SkinOverlayData", tagList); + } else if (!glowTexture.isEmpty()) { + nbttagcompound.getTagList("SkinOverlayData", 10).appendTag(compound); + glowTexture = ""; + } + } + + NBTTagList skinOverlayList = nbttagcompound.getTagList("SkinOverlayData",10); + for (int i = 0; i < skinOverlayList.tagCount(); i++) { + int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID"); + String tagString = skinOverlayList.getCompoundTagAt(i).getString("SkinOverlayTexture"); + boolean glow = skinOverlayList.getCompoundTagAt(i).getBoolean("SkinOverlayGlow"); + float alpha = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayAlpha"); + float size = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySize"); + float speedX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySpeedX"); + float speedY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySpeedY"); + float scaleX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayScaleX"); + float scaleY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayScaleY"); + float offsetX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetX"); + float offsetY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetY"); + float offsetZ = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetZ"); + + skinOverlays.put(tagID,new SkinOverlayData(tagString,glow,alpha,size,speedX,speedY,scaleX,scaleY,offsetX,offsetY,offsetZ)); + } modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE); if(modelSize > CustomNpcs.NpcSizeLimit) diff --git a/src/main/java/noppes/npcs/PacketHandlerServer.java b/src/main/java/noppes/npcs/PacketHandlerServer.java index 576d69ffb..aa478c0ed 100644 --- a/src/main/java/noppes/npcs/PacketHandlerServer.java +++ b/src/main/java/noppes/npcs/PacketHandlerServer.java @@ -148,7 +148,7 @@ public class PacketHandlerServer{ public void updateSkinOverlays(EntityPlayerMP player) { NBTTagCompound data = new NBTTagCompound(); data.setTag("SkinOverlayData",player.getEntityData().getTagList("SkinOverlayData",10)); - Server.sendData(player, EnumPacketClient.CLIENT_UPDATE_SKIN_OVERLAYS, data); + Server.sendData(player, EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS, data); } private void getScriptsEnabled(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException { diff --git a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java index 75d81209a..529013059 100644 --- a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java @@ -439,7 +439,7 @@ public class ScriptPlayerEventHandler { if (playerMP.getEntityData().hasKey("SkinOverlayData")) { NBTTagCompound data = new NBTTagCompound(); data.setTag("SkinOverlayData",playerMP.getEntityData().getTagList("SkinOverlayData",10)); - Server.sendData(playerMP, EnumPacketClient.CLIENT_UPDATE_SKIN_OVERLAYS, data); + Server.sendData(playerMP, EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS, data); } } } diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index c29fabf27..2dfd659bd 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -13,6 +13,8 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -37,6 +39,7 @@ import noppes.npcs.controllers.Dialog; import noppes.npcs.controllers.DialogController; import noppes.npcs.controllers.Quest; import noppes.npcs.controllers.data.SkinOverlayData; +import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.Sys; @@ -90,7 +93,7 @@ public class NoppesUtil { float offsetY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetY"); float offsetZ = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetZ"); - skinOverlays.put(tagID,new SkinOverlayData(new ResourceLocation(tagString),glow,alpha,size,speedX,speedY,scaleX,scaleY,offsetX,offsetY,offsetZ)); + skinOverlays.put(tagID,new SkinOverlayData(tagString,glow,alpha,size,speedX,speedY,scaleX,scaleY,offsetX,offsetY,offsetZ)); } Client.skinOverlays.put(player.getUniqueID(), skinOverlays); } diff --git a/src/main/java/noppes/npcs/client/PacketHandlerClient.java b/src/main/java/noppes/npcs/client/PacketHandlerClient.java index d9921ea53..f7baf4fba 100644 --- a/src/main/java/noppes/npcs/client/PacketHandlerClient.java +++ b/src/main/java/noppes/npcs/client/PacketHandlerClient.java @@ -273,7 +273,7 @@ public class PacketHandlerClient extends PacketHandlerServer{ else if(type == EnumPacketClient.SWING_PLAYER_ARM){ Minecraft.getMinecraft().thePlayer.swingItem(); } - else if(type == EnumPacketClient.CLIENT_UPDATE_SKIN_OVERLAYS) { + else if(type == EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS) { NoppesUtil.updateSkinOverlayData(player, Server.readNBT(buffer)); } } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java b/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java index d701bc72e..7c89bd03d 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java @@ -4,23 +4,27 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.util.ResourceLocation; +import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.opengl.GL11; public class GuiNpcTextureOverlays extends GuiNpcSelectionInterface{ public GuiNpcTextureOverlays(EntityNPCInterface npc,GuiScreen parent){ - super(npc, parent, npc.display.glowTexture.isEmpty()?"customnpcs:textures/overlays/":npc.display.glowTexture); - title = "Select Overlay"; + //super(npc, parent, npc.display.glowTexture.isEmpty()?"customnpcs:textures/overlays/":npc.display.glowTexture); + super(npc, parent, npc.display.skinOverlays.containsKey(0) ? npc.display.skinOverlays.get(0).directory : ""); + title = "Select Overlay"; this.parent = parent; } public void initGui(){ super.initGui(); - int index = npc.display.glowTexture.lastIndexOf("/"); + String str = npc.display.skinOverlays.containsKey(0) ? npc.display.skinOverlays.get(0).directory : ""; + int index = str.lastIndexOf("/"); if(index > 0){ - String asset = npc.display.glowTexture.substring(index + 1); - if(npc.display.glowTexture.equals(assets.getAsset(asset))) + String asset = str.substring(index + 1); + if(str.equals(assets.getAsset(asset))) slot.selected = asset; } } @@ -73,8 +77,13 @@ public class GuiNpcTextureOverlays extends GuiNpcSelectionInterface{ @Override public void elementClicked(){ if(dataTextures.contains(slot.selected) && slot.selected != null){ - npc.display.glowTexture = assets.getAsset(slot.selected); + //npc.display.glowTexture = assets.getAsset(slot.selected); npc.textureGlowLocation = null; + + npc.display.skinOverlays.put(0,new SkinOverlayData( + assets.getAsset(slot.selected), true, 0.8F, 1.0F, 0.0F, 0.0F, + 1.0F, 1.0F, 0.0F, 0.0F, 0.0F + )); } } diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java index ca2055e63..fa4492ebc 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java @@ -4,6 +4,7 @@ import com.mojang.authlib.GameProfile; import net.minecraft.client.gui.GuiButton; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; import noppes.npcs.CustomNpcs; import noppes.npcs.DataDisplay; import noppes.npcs.client.Client; @@ -15,6 +16,7 @@ import noppes.npcs.client.gui.SubGuiNpcName; import noppes.npcs.client.gui.model.GuiCreationScreen; import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumPacketServer; +import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; @@ -76,7 +78,8 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene y+=23; addLabel(new GuiNpcLabel(9,"display.overlay", guiLeft + 5, y + 5)); - addTextField(new GuiNpcTextField(9,this, fontRendererObj, guiLeft + 80, y, 200, 20, display.glowTexture)); + + addTextField(new GuiNpcTextField(9,this, fontRendererObj, guiLeft + 80, y, 200, 20, npc.display.skinOverlays.containsKey(0) ? npc.display.skinOverlays.get(0).directory : "")); this.addButton(new GuiNpcButton(9, guiLeft + 283, y, 80, 20, "display.selectTexture")); y+=23; @@ -128,7 +131,11 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene } else if(textfield.id == 9){ npc.textureGlowLocation = null; - display.glowTexture = textfield.getText(); + //display.glowTexture = textfield.getText(); + npc.display.skinOverlays.put(0,new SkinOverlayData( + textfield.getText(), true, 0.8F, 1.0F, 0.0F, 0.0F, + 1.0F, 1.0F, 0.0F, 0.0F, 0.0F + )); } else if(textfield.id == 11){ display.title = textfield.getText(); diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java index 8abf61f8a..6af7252db 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java @@ -21,6 +21,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagByte; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import noppes.npcs.client.Client; import noppes.npcs.client.gui.util.GuiCustomScroll; @@ -30,6 +31,7 @@ import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.ICustomScrollListener; import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.controllers.PixelmonHelper; +import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityFakeLiving; import noppes.npcs.entity.EntityNPCInterface; @@ -229,7 +231,8 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol npc.display.texture = NPCRendererHelper.getTexture(render,entity); } } - npc.display.glowTexture = ""; + //npc.display.glowTexture = ""; + npc.display.skinOverlays.remove(0); npc.textureLocation = null; npc.textureGlowLocation = null; npc.updateHitbox(); @@ -336,7 +339,8 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol else{ npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; } - npc.display.glowTexture = ""; + //npc.display.glowTexture = ""; + npc.display.skinOverlays.remove(0); npc.textureLocation = null; npc.textureGlowLocation = null; npc.updateHitbox(); diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java b/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java index 727cd19ba..c0eb3228f 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java @@ -12,11 +12,13 @@ import net.minecraft.client.renderer.entity.NPCRendererHelper; import net.minecraft.client.renderer.entity.RendererLivingEntity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.ResourceLocation; import noppes.npcs.ModelData; import noppes.npcs.client.EntityUtil; import noppes.npcs.client.gui.util.GuiNPCInterface; import noppes.npcs.client.gui.util.GuiNPCStringSlot; import noppes.npcs.client.gui.util.GuiNpcButton; +import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.entity.EntityCustomNpc; import org.lwjgl.opengl.GL11; @@ -127,7 +129,8 @@ public class GuiEntitySelection extends GuiNPCInterface else{ npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; } - npc.display.glowTexture = ""; + //npc.display.glowTexture = ""; + npc.display.skinOverlays.remove(0); npc.textureLocation = null; npc.textureGlowLocation = null; npc.updateHitbox(); diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index d15e5df01..ae2a5bbf8 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -93,6 +93,15 @@ public class RenderCNPCPlayer extends RenderPlayer { if (Client.skinOverlays.containsKey(player.getUniqueID())) { for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { + if (overlayData.location == null) { + overlayData.location = new ResourceLocation(overlayData.directory); + } else { + String str = overlayData.location.getResourceDomain()+":"+overlayData.location.getResourcePath(); + if (!str.equals(overlayData.directory)) { + overlayData.location = new ResourceLocation(overlayData.directory); + } + } + if (!preRenderOverlay(false, player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size, overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY, overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ @@ -135,6 +144,15 @@ public class RenderCNPCPlayer extends RenderPlayer { if (Client.skinOverlays.containsKey(player.getUniqueID())) { for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { + if (overlayData.location == null) { + overlayData.location = new ResourceLocation(overlayData.directory); + } else { + String str = overlayData.location.getResourceDomain()+":"+overlayData.location.getResourcePath(); + if (!str.equals(overlayData.directory)) { + overlayData.location = new ResourceLocation(overlayData.directory); + } + } + if (!preRenderOverlay(false, player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size, overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY, overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index 01deba024..3a5c93c1d 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -24,6 +24,7 @@ import noppes.npcs.client.ImageDownloadAlt; import noppes.npcs.client.model.ModelMPM; import noppes.npcs.constants.EnumAnimation; import noppes.npcs.constants.EnumStandingType; +import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; @@ -208,115 +209,69 @@ public class RenderNPCInterface extends RenderLiving{ super.doRender(entityliving, d, d1, d2, f, f1); } - protected void renderModel(EntityLivingBase entityliving, float par2, float par3, float par4, float par5, float par6, float par7){ + protected void renderModel(EntityLivingBase entityliving, float par2, float par3, float par4, float par5, float par6, float par7) { super.renderModel(entityliving, par2, par3, par4, par5, par6, par7); EntityNPCInterface npc = (EntityNPCInterface) entityliving; - if (!npc.display.glowTexture.isEmpty() && !npc.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) - { - if(npc.textureGlowLocation == null){ - npc.textureGlowLocation = new ResourceLocation(npc.display.glowTexture); - } else { - String locationString = npc.textureGlowLocation.getResourceDomain() + ":" + npc.textureGlowLocation.getResourcePath(); - if (!locationString.equals(npc.display.glowTexture)) { - npc.textureGlowLocation = new ResourceLocation(npc.display.glowTexture); + + if (!npc.display.skinOverlays.isEmpty()) { + for (SkinOverlayData overlayData : npc.display.skinOverlays.values()) { + try { + if (overlayData.location == null) { + overlayData.location = new ResourceLocation(overlayData.directory); + } else { + String str = npc.display.skinOverlays.get(0).location.getResourceDomain()+":"+npc.display.skinOverlays.get(0).location.getResourcePath(); + if (!str.equals(overlayData.directory)) { + overlayData.location = new ResourceLocation(overlayData.directory); + } + } + + this.bindTexture(overlayData.location); + + // Overlay & Glow + if (overlayData.glow) { + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); + Minecraft.getMinecraft().entityRenderer.disableLightmap((double) 0); + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, overlayData.alpha); + + GL11.glDepthMask(!npc.isInvisible()); + + GL11.glPushMatrix(); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glTranslatef(npc.display.overlayRenderTicks * 0.001F * overlayData.speedX, npc.display.overlayRenderTicks * 0.001F * overlayData.speedY, 0.0F); + GL11.glScalef(overlayData.scaleX, overlayData.scaleY, 1.0F); + + GL11.glMatrixMode(GL11.GL_MODELVIEW); + float scale = 1.005f * overlayData.size; + GL11.glTranslatef(overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ); + GL11.glScalef(scale, scale, scale); + if(mainModel instanceof ModelMPM){ + ((ModelMPM)mainModel).isArmor = true; + mainModel.render(entityliving, par2, par3, par4, par5, par6, par7); + ((ModelMPM)mainModel).isArmor = false; + } + else + mainModel.render(entityliving, par2, par3, par4, par5, par6, par7); + GL11.glPopMatrix(); + + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glDisable(GL11.GL_BLEND); + Minecraft.getMinecraft().entityRenderer.enableLightmap((double) 0); + } catch (Exception ignored) { } } - - bindTexture((ResourceLocation) npc.textureGlowLocation); - float f1 = 1.0F; - - // Overlay & Glow - GL11.glDepthFunc(GL11.GL_LEQUAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); - GL11.glDisable(GL11.GL_LIGHTING); - Minecraft.getMinecraft().entityRenderer.disableLightmap((double)0); - - GL11.glDepthMask(!npc.isInvisible()); - GL11.glColor4f(1.0F, 1.0F, 1.0F, npc.isInvisible() ? 0.2F : 1.0F); - - GL11.glPushMatrix(); - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glLoadIdentity(); - GL11.glScalef(npc.display.overlayScaleX, npc.display.overlayScaleY, 1.0F); - - GL11.glMatrixMode(GL11.GL_MODELVIEW); - float scale = 1.001f * npc.display.overlaySize; - GL11.glScalef(scale, scale, scale); - if(mainModel instanceof ModelMPM){ - ((ModelMPM)mainModel).isArmor = true; - mainModel.render(entityliving, par2, par3, par4, par5, par6, par7); - ((ModelMPM)mainModel).isArmor = false; - } - else - mainModel.render(entityliving, par2, par3, par4, par5, par6, par7); - GL11.glPopMatrix(); - - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glLoadIdentity(); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glColor4f(1.0F, 1.0F, 1.0F, f1); - GL11.glDepthFunc(GL11.GL_LEQUAL); - GL11.glDisable(GL11.GL_BLEND); - Minecraft.getMinecraft().entityRenderer.enableLightmap((double)0); - } - - if (!npc.display.poweredTexture.isEmpty() && !npc.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) - { - if(npc.texturePoweredLocation == null){ - npc.texturePoweredLocation = new ResourceLocation(npc.display.poweredTexture); - } else { - String locationString = npc.texturePoweredLocation.getResourceDomain() + ":" + npc.texturePoweredLocation.getResourcePath(); - if (!locationString.equals(npc.display.poweredTexture)) { - npc.texturePoweredLocation = new ResourceLocation(npc.display.poweredTexture); - } - } - - bindTexture((ResourceLocation) npc.texturePoweredLocation); - float f1 = 1.0F; - - // Overlay & Glow - GL11.glDepthFunc(GL11.GL_LEQUAL); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); - GL11.glDisable(GL11.GL_LIGHTING); - Minecraft.getMinecraft().entityRenderer.disableLightmap((double)0); - - GL11.glDepthMask(!npc.isInvisible()); - GL11.glColor4f(1.0F, 1.0F, 1.0F, npc.isInvisible() ? 0.2F : 1.0F); - - GL11.glPushMatrix(); - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glLoadIdentity(); - GL11.glTranslatef(npc.renderTicksPowered * 0.001F * npc.display.poweredSpeedX, npc.renderTicksPowered * 0.001F * npc.display.poweredSpeedY, 0.0F); - GL11.glScalef(npc.display.poweredScaleX, npc.display.poweredScaleY, 1.0F); - - GL11.glMatrixMode(GL11.GL_MODELVIEW); - float scale = 1.001f * npc.display.poweredSize; - GL11.glScalef(scale, scale, scale); - GL11.glEnable(GL11.GL_BLEND); - if(mainModel instanceof ModelMPM){ - ((ModelMPM)mainModel).isArmor = true; - mainModel.render(entityliving, par2, par3, par4, par5, par6, par7); - ((ModelMPM)mainModel).isArmor = false; - } - else - mainModel.render(entityliving, par2, par3, par4, par5, par6, par7); - GL11.glPopMatrix(); - - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glLoadIdentity(); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glColor4f(1.0F, 1.0F, 1.0F, f1); - GL11.glDepthFunc(GL11.GL_LEQUAL); - GL11.glDisable(GL11.GL_BLEND); - Minecraft.getMinecraft().entityRenderer.enableLightmap((double)0); - - npc.renderTicksPowered++; + npc.display.overlayRenderTicks++; } } @Override diff --git a/src/main/java/noppes/npcs/constants/EnumPacketClient.java b/src/main/java/noppes/npcs/constants/EnumPacketClient.java index 044959ccc..3ab209708 100644 --- a/src/main/java/noppes/npcs/constants/EnumPacketClient.java +++ b/src/main/java/noppes/npcs/constants/EnumPacketClient.java @@ -38,5 +38,5 @@ public enum EnumPacketClient { OVERLAY_CLOSE, SWING_PLAYER_ARM, UPDATE_ITEM, - CLIENT_UPDATE_SKIN_OVERLAYS + PLAYER_UPDATE_SKIN_OVERLAYS } diff --git a/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java b/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java index 8b6f0bdc7..2b201e419 100644 --- a/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java +++ b/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java @@ -3,7 +3,8 @@ package noppes.npcs.controllers.data; import net.minecraft.util.ResourceLocation; public class SkinOverlayData { - public ResourceLocation location; + public ResourceLocation location = null; + public String directory; public boolean glow; public float alpha = 1.0F; public float size = 1.0F; @@ -18,9 +19,9 @@ public class SkinOverlayData { public float offsetY = 0.0F; public float offsetZ = 0.0F; - public SkinOverlayData(ResourceLocation location, boolean glow, float alpha, float size, float speedX, float speedY, + public SkinOverlayData(String directory, boolean glow, float alpha, float size, float speedX, float speedY, float scaleX, float scaleY, float offsetX, float offsetY, float offsetZ) { - this.location = location; + this.directory = directory; this.glow = glow; this.alpha = alpha; this.size = size; diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 164b7c95c..d576c5e8e 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -120,7 +120,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti public long totalTicksAlive = 0; private int taskCount = 1; public int lastInteract = 0; - public long renderTicksPowered = 0; public Faction faction; //should only be used server side @@ -131,7 +130,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti public ResourceLocation textureLocation = null; public ResourceLocation textureGlowLocation = null; - public ResourceLocation texturePoweredLocation = null; public ResourceLocation textureCloakLocation = null; public EnumAnimation currentAnimation = EnumAnimation.NONE; diff --git a/src/main/java/noppes/npcs/entity/old/EntityNPCEnderman.java b/src/main/java/noppes/npcs/entity/old/EntityNPCEnderman.java index 8d0b237d8..6d983b834 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNPCEnderman.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNPCEnderman.java @@ -6,9 +6,11 @@ package noppes.npcs.entity.old; import net.minecraft.entity.monster.EntityEnderman; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import noppes.npcs.ModelData; import noppes.npcs.constants.EnumAnimation; +import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.entity.EntityCustomNpc; public class EntityNPCEnderman extends EntityNpcEnderchibi @@ -17,7 +19,11 @@ public class EntityNPCEnderman extends EntityNpcEnderchibi { super(world); display.texture = "customnpcs:textures/entity/enderman/enderman.png"; - display.glowTexture = "customnpcs:textures/overlays/ender_eyes.png"; + //display.glowTexture = ; + display.skinOverlays.put(0,new SkinOverlayData( + "customnpcs:textures/overlays/ender_eyes.png", true, 0.8F, 1.0F, 0.0F, 0.0F, + 1.0F, 1.0F, 0.0F, 0.0F, 0.0F + )); this.width = 0.6F; this.height = 2.9F; } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index 58f416ad2..da46cd42b 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -1,13 +1,20 @@ package noppes.npcs.scripted.entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.ResourceLocation; import noppes.npcs.CustomNpcs; import noppes.npcs.NoppesUtilServer; +import noppes.npcs.Server; import noppes.npcs.constants.*; import noppes.npcs.controllers.Line; +import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.ScriptFaction; +import noppes.npcs.scripted.ScriptSkinOverlay; +import noppes.npcs.scripted.interfaces.ISkinOverlay; import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.item.IItemStack; @@ -34,6 +41,7 @@ import noppes.npcs.scripted.NpcAPI; import noppes.npcs.util.ValueUtil; import java.util.ArrayList; +import java.util.HashMap; import java.util.UUID; public class ScriptNpc extends ScriptLiving implements ICustomNpc { @@ -1095,47 +1103,28 @@ public class ScriptNpc extends ScriptLiving imp } public void setOverlayTexture(String overlayTexture) { - npc.display.glowTexture = overlayTexture; - npc.script.clientNeedsUpdate = true; + this.setSkinOverlay(0, NpcAPI.Instance().createSkinOverlay(overlayTexture)); } - public String getOverlayTexture() {return npc.display.glowTexture;} + public String getOverlayTexture() { + if (!npc.display.skinOverlays.containsKey(0)) + return ""; - public void setOverlaySize(float size) { - npc.display.overlaySize = size; + return npc.display.skinOverlays.get(0).directory; } - public float getOverlaySize() {return npc.display.overlaySize;} - public void setOverlayScale(float scaleX, float scaleY) { - npc.display.overlayScaleX = scaleX; - npc.display.overlayScaleY = scaleY; + public void setSkinOverlay(int id, ISkinOverlay overlay) { + if (overlay != null) { + npc.display.skinOverlays.put(id, new SkinOverlayData( + overlay.getTexture(),overlay.getGlow(),overlay.getAlpha(),overlay.getSize(), + overlay.getSpeedX(),overlay.getSpeedY(),overlay.getScaleX(),overlay.getScaleY(), + overlay.getOffsetX(),overlay.getOffsetY(),overlay.getOffsetZ() + )); + } } - public float getOverlayTextureScaleX() {return npc.display.overlayScaleX;} - public float getOverlayTextureScaleY() {return npc.display.overlayScaleY;} - public void setPoweredTexture(String poweredTexture) { - npc.display.poweredTexture = poweredTexture; - npc.script.clientNeedsUpdate = true; + public void removeSkinOverlay(int id) { + npc.display.skinOverlays.remove(id); } - public String getPoweredTexture() {return npc.display.poweredTexture;} - - public void setPoweredSize(float size) { - npc.display.poweredSize = size; - } - public float getPoweredSize() {return npc.display.poweredSize;} - - public void setPoweredScale(float scaleX, float scaleY) { - npc.display.poweredScaleX = scaleX; - npc.display.poweredScaleY = scaleY; - } - public float getPoweredTextureScaleX() {return npc.display.poweredScaleX;} - public float getPoweredTextureScaleY() {return npc.display.poweredScaleY;} - - public void setPoweredSpeed(float speedX, float speedY) { - npc.display.poweredSpeedX = speedX; - npc.display.poweredSpeedY = speedY; - } - public float getPoweredSpeedX() {return npc.display.poweredSpeedX;} - public float getPoweredSpeedY() {return npc.display.poweredSpeedY;} public void setCollisionType(int type){ npc.display.collidesWith = type; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index f787d8821..5fe85514b 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -527,7 +527,11 @@ public class ScriptPlayer extends ScriptLivingBase Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.OVERLAY_CLOSE, id, new NBTTagCompound()); } - public void setSkinOverlay(int id, ScriptSkinOverlay overlay) { + public void setSkinOverlay(int id, ISkinOverlay overlay) { + if (id < 0) { + throw new CustomNPCsException("Skin overlay ID must be greater than 0."); + } + if (overlay != null) { NBTTagCompound data = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound(); @@ -559,7 +563,7 @@ public class ScriptPlayer extends ScriptLivingBase player.getEntityData().getTagList("SkinOverlayData", 10).appendTag(compound); } data.setTag("SkinOverlayData",player.getEntityData().getTagList("SkinOverlayData",10)); - Server.sendData((EntityPlayerMP) this.entity, EnumPacketClient.CLIENT_UPDATE_SKIN_OVERLAYS, data); + Server.sendData((EntityPlayerMP) this.entity, EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS, data); } } @@ -573,7 +577,7 @@ public class ScriptPlayer extends ScriptLivingBase } } data.setTag("SkinOverlayData",player.getEntityData().getTagList("SkinOverlayData",10)); - Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.CLIENT_UPDATE_SKIN_OVERLAYS, data); + Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS, data); } } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java index 7d3fef7fd..8b9efff78 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java @@ -738,10 +738,6 @@ public interface ICustomNpc extends IEntityLiving { String getOverlayTexture(); - void setPoweredTexture(String poweredTexture); - - String getPoweredTexture(); - void setCollisionType(int type); int getCollisionType(); From 41401d05218b095ddac26f0bf5221a0069c23242 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 17 May 2022 04:46:06 -0500 Subject: [PATCH 53/75] Removed redundant ScriptSkinOverlay, using SkinOverlayData in place of it, which now implements ISkinOverlay. --- src/main/java/noppes/npcs/DataDisplay.java | 30 +++---- .../client/gui/GuiNpcTextureOverlays.java | 5 +- .../client/gui/mainmenu/GuiNpcDisplay.java | 3 +- .../client/renderer/RenderCNPCPlayer.java | 13 ++- .../client/renderer/RenderNPCInterface.java | 28 +++--- .../controllers/data/SkinOverlayData.java | 87 ++++++++++++++++-- .../java/noppes/npcs/scripted/NpcAPI.java | 3 +- .../npcs/scripted/ScriptSkinOverlay.java | 89 ------------------- .../npcs/scripted/entity/ScriptNpc.java | 14 +-- .../scripted/interfaces/ISkinOverlay.java | 5 ++ 10 files changed, 128 insertions(+), 149 deletions(-) delete mode 100644 src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java diff --git a/src/main/java/noppes/npcs/DataDisplay.java b/src/main/java/noppes/npcs/DataDisplay.java index befd353fc..0afd70fd6 100644 --- a/src/main/java/noppes/npcs/DataDisplay.java +++ b/src/main/java/noppes/npcs/DataDisplay.java @@ -2,17 +2,15 @@ package noppes.npcs; import java.util.*; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; import net.minecraft.nbt.NBTUtil; import net.minecraft.server.MinecraftServer; import net.minecraft.util.StringUtils; -import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.scripted.interfaces.ISkinOverlay; import noppes.npcs.util.ValueUtil; import com.google.common.collect.Iterables; @@ -36,7 +34,7 @@ public class DataDisplay { public String texture = "customnpcs:textures/entity/humanmale/Steve.png"; public String cloakTexture = ""; - public HashMap skinOverlays = new HashMap<>(); + public HashMap skinOverlays = new HashMap<>(); public long overlayRenderTicks = 0; public String glowTexture = ""; @@ -71,20 +69,20 @@ public class DataDisplay { public NBTTagCompound writeOverlaysToNBT(NBTTagCompound nbttagcompound) { NBTTagList overlayList = new NBTTagList(); if (!npc.display.skinOverlays.isEmpty()) { - for (Map.Entry overlayData : npc.display.skinOverlays.entrySet()) { + for (Map.Entry overlayData : npc.display.skinOverlays.entrySet()) { NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("SkinOverlayID", overlayData.getKey()); - compound.setString("SkinOverlayTexture", overlayData.getValue().directory); - compound.setBoolean("SkinOverlayGlow", overlayData.getValue().glow); - compound.setFloat("SkinOverlayAlpha", overlayData.getValue().alpha); - compound.setFloat("SkinOverlaySize", overlayData.getValue().size); - compound.setFloat("SkinOverlaySpeedX", overlayData.getValue().speedX); - compound.setFloat("SkinOverlaySpeedY", overlayData.getValue().speedY); - compound.setFloat("SkinOverlayScaleX", overlayData.getValue().scaleX); - compound.setFloat("SkinOverlayScaleY", overlayData.getValue().scaleY); - compound.setFloat("SkinOverlayOffsetX", overlayData.getValue().offsetX); - compound.setFloat("SkinOverlayOffsetY", overlayData.getValue().offsetY); - compound.setFloat("SkinOverlayOffsetZ", overlayData.getValue().offsetZ); + compound.setString("SkinOverlayTexture", overlayData.getValue().getTexture()); + compound.setBoolean("SkinOverlayGlow", overlayData.getValue().getGlow()); + compound.setFloat("SkinOverlayAlpha", overlayData.getValue().getAlpha()); + compound.setFloat("SkinOverlaySize", overlayData.getValue().getSize()); + compound.setFloat("SkinOverlaySpeedX", overlayData.getValue().getSpeedX()); + compound.setFloat("SkinOverlaySpeedY", overlayData.getValue().getSpeedY()); + compound.setFloat("SkinOverlayScaleX", overlayData.getValue().getScaleX()); + compound.setFloat("SkinOverlayScaleY", overlayData.getValue().getScaleY()); + compound.setFloat("SkinOverlayOffsetX", overlayData.getValue().getOffsetX()); + compound.setFloat("SkinOverlayOffsetY", overlayData.getValue().getOffsetY()); + compound.setFloat("SkinOverlayOffsetZ", overlayData.getValue().getOffsetZ()); overlayList.appendTag(compound); } } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java b/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java index 7c89bd03d..e7166693d 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java @@ -4,7 +4,6 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.util.ResourceLocation; import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.entity.EntityNPCInterface; @@ -13,14 +12,14 @@ import org.lwjgl.opengl.GL11; public class GuiNpcTextureOverlays extends GuiNpcSelectionInterface{ public GuiNpcTextureOverlays(EntityNPCInterface npc,GuiScreen parent){ //super(npc, parent, npc.display.glowTexture.isEmpty()?"customnpcs:textures/overlays/":npc.display.glowTexture); - super(npc, parent, npc.display.skinOverlays.containsKey(0) ? npc.display.skinOverlays.get(0).directory : ""); + super(npc, parent, npc.display.skinOverlays.containsKey(0) ? npc.display.skinOverlays.get(0).getTexture() : ""); title = "Select Overlay"; this.parent = parent; } public void initGui(){ super.initGui(); - String str = npc.display.skinOverlays.containsKey(0) ? npc.display.skinOverlays.get(0).directory : ""; + String str = npc.display.skinOverlays.containsKey(0) ? npc.display.skinOverlays.get(0).getTexture() : ""; int index = str.lastIndexOf("/"); if(index > 0){ String asset = str.substring(index + 1); diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java index fa4492ebc..5189c34d5 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java @@ -4,7 +4,6 @@ import com.mojang.authlib.GameProfile; import net.minecraft.client.gui.GuiButton; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; import noppes.npcs.CustomNpcs; import noppes.npcs.DataDisplay; import noppes.npcs.client.Client; @@ -79,7 +78,7 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene y+=23; addLabel(new GuiNpcLabel(9,"display.overlay", guiLeft + 5, y + 5)); - addTextField(new GuiNpcTextField(9,this, fontRendererObj, guiLeft + 80, y, 200, 20, npc.display.skinOverlays.containsKey(0) ? npc.display.skinOverlays.get(0).directory : "")); + addTextField(new GuiNpcTextField(9,this, fontRendererObj, guiLeft + 80, y, 200, 20, npc.display.skinOverlays.containsKey(0) ? npc.display.skinOverlays.get(0).getTexture() : "")); this.addButton(new GuiNpcButton(9, guiLeft + 283, y, 80, 20, "display.selectTexture")); y+=23; diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index ae2a5bbf8..69a6e3440 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -1,6 +1,5 @@ package noppes.npcs.client.renderer; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -94,11 +93,11 @@ public class RenderCNPCPlayer extends RenderPlayer { if (Client.skinOverlays.containsKey(player.getUniqueID())) { for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { if (overlayData.location == null) { - overlayData.location = new ResourceLocation(overlayData.directory); + overlayData.location = new ResourceLocation(overlayData.texture); } else { String str = overlayData.location.getResourceDomain()+":"+overlayData.location.getResourcePath(); - if (!str.equals(overlayData.directory)) { - overlayData.location = new ResourceLocation(overlayData.directory); + if (!str.equals(overlayData.texture)) { + overlayData.location = new ResourceLocation(overlayData.texture); } } @@ -145,11 +144,11 @@ public class RenderCNPCPlayer extends RenderPlayer { if (Client.skinOverlays.containsKey(player.getUniqueID())) { for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { if (overlayData.location == null) { - overlayData.location = new ResourceLocation(overlayData.directory); + overlayData.location = new ResourceLocation(overlayData.texture); } else { String str = overlayData.location.getResourceDomain()+":"+overlayData.location.getResourcePath(); - if (!str.equals(overlayData.directory)) { - overlayData.location = new ResourceLocation(overlayData.directory); + if (!str.equals(overlayData.texture)) { + overlayData.location = new ResourceLocation(overlayData.texture); } } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index 3a5c93c1d..a76edeb42 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -19,7 +19,6 @@ import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.BossStatus; import net.minecraft.util.ResourceLocation; -import noppes.npcs.client.ClientProxy; import noppes.npcs.client.ImageDownloadAlt; import noppes.npcs.client.model.ModelMPM; import noppes.npcs.constants.EnumAnimation; @@ -28,6 +27,7 @@ import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.scripted.interfaces.ISkinOverlay; import org.lwjgl.opengl.GL11; import com.mojang.authlib.minecraft.MinecraftProfileTexture; @@ -214,21 +214,21 @@ public class RenderNPCInterface extends RenderLiving{ EntityNPCInterface npc = (EntityNPCInterface) entityliving; if (!npc.display.skinOverlays.isEmpty()) { - for (SkinOverlayData overlayData : npc.display.skinOverlays.values()) { + for (ISkinOverlay overlayData : npc.display.skinOverlays.values()) { try { - if (overlayData.location == null) { - overlayData.location = new ResourceLocation(overlayData.directory); + if (overlayData.getLocation() == null) { + overlayData.setLocation(new ResourceLocation(overlayData.getTexture())); } else { - String str = npc.display.skinOverlays.get(0).location.getResourceDomain()+":"+npc.display.skinOverlays.get(0).location.getResourcePath(); - if (!str.equals(overlayData.directory)) { - overlayData.location = new ResourceLocation(overlayData.directory); + String str = npc.display.skinOverlays.get(0).getLocation().getResourceDomain()+":"+npc.display.skinOverlays.get(0).getLocation().getResourcePath(); + if (!str.equals(overlayData.getTexture())) { + overlayData.setLocation(new ResourceLocation(overlayData.getTexture())); } } - this.bindTexture(overlayData.location); + this.bindTexture(overlayData.getLocation()); // Overlay & Glow - if (overlayData.glow) { + if (overlayData.getGlow()) { GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LIGHTING); @@ -236,19 +236,19 @@ public class RenderNPCInterface extends RenderLiving{ Minecraft.getMinecraft().entityRenderer.disableLightmap((double) 0); } - GL11.glColor4f(1.0F, 1.0F, 1.0F, overlayData.alpha); + GL11.glColor4f(1.0F, 1.0F, 1.0F, overlayData.getAlpha()); GL11.glDepthMask(!npc.isInvisible()); GL11.glPushMatrix(); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); - GL11.glTranslatef(npc.display.overlayRenderTicks * 0.001F * overlayData.speedX, npc.display.overlayRenderTicks * 0.001F * overlayData.speedY, 0.0F); - GL11.glScalef(overlayData.scaleX, overlayData.scaleY, 1.0F); + GL11.glTranslatef(npc.display.overlayRenderTicks * 0.001F * overlayData.getSpeedX(), npc.display.overlayRenderTicks * 0.001F * overlayData.getSpeedY(), 0.0F); + GL11.glScalef(overlayData.getScaleX(), overlayData.getScaleY(), 1.0F); GL11.glMatrixMode(GL11.GL_MODELVIEW); - float scale = 1.005f * overlayData.size; - GL11.glTranslatef(overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ); + float scale = 1.005f * overlayData.getSize(); + GL11.glTranslatef(overlayData.getOffsetX(), overlayData.getOffsetY(), overlayData.getOffsetZ()); GL11.glScalef(scale, scale, scale); if(mainModel instanceof ModelMPM){ ((ModelMPM)mainModel).isArmor = true; diff --git a/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java b/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java index 2b201e419..07466ce87 100644 --- a/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java +++ b/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java @@ -1,11 +1,12 @@ package noppes.npcs.controllers.data; import net.minecraft.util.ResourceLocation; +import noppes.npcs.scripted.interfaces.ISkinOverlay; -public class SkinOverlayData { +public class SkinOverlayData implements ISkinOverlay { public ResourceLocation location = null; - public String directory; - public boolean glow; + public String texture; + public boolean glow = true; public float alpha = 1.0F; public float size = 1.0F; @@ -19,9 +20,13 @@ public class SkinOverlayData { public float offsetY = 0.0F; public float offsetZ = 0.0F; - public SkinOverlayData(String directory, boolean glow, float alpha, float size, float speedX, float speedY, + public SkinOverlayData(String texture) { + this.texture = texture; + } + + public SkinOverlayData(String texture, boolean glow, float alpha, float size, float speedX, float speedY, float scaleX, float scaleY, float offsetX, float offsetY, float offsetZ) { - this.directory = directory; + this.texture = texture; this.glow = glow; this.alpha = alpha; this.size = size; @@ -33,4 +38,76 @@ public class SkinOverlayData { this.offsetY = offsetY; this.offsetZ = offsetZ; } + + public void setTexture(String texture) { + this.texture = texture; + } + public String getTexture() { + return texture; + } + + public void setGlow(boolean glow) { + this.glow = glow; + } + public boolean getGlow() { + return glow; + } + + public void setAlpha(float alpha) { + this.alpha = alpha; + } + public float getAlpha() { + return alpha; + } + + public void setSize(float size) { + this.size = size; + } + public float getSize() { + return size; + } + + public void setScale(float scaleX, float scaleY) { + this.scaleX = scaleX; + this.scaleY = scaleY; + } + public float getScaleX() { + return scaleX; + } + public float getScaleY() { + return scaleY; + } + + public void setSpeed(float speedX, float speedY) { + this.speedX = speedX; + this.speedY = speedY; + } + public float getSpeedX() { + return speedX; + } + public float getSpeedY() { + return speedY; + } + + public void setOffset(float offsetX, float offsetY, float offsetZ) { + this.offsetX = offsetX; + this.offsetY = offsetY; + this.offsetZ = offsetZ; + } + public float getOffsetX() { + return offsetX; + } + public float getOffsetY() { + return offsetY; + } + public float getOffsetZ() { + return offsetZ; + } + + public void setLocation(ResourceLocation location) { + this.location = location; + } + public ResourceLocation getLocation() { + return this.location; + } } diff --git a/src/main/java/noppes/npcs/scripted/NpcAPI.java b/src/main/java/noppes/npcs/scripted/NpcAPI.java index 7b4ad5113..49b46d13a 100644 --- a/src/main/java/noppes/npcs/scripted/NpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/NpcAPI.java @@ -31,6 +31,7 @@ import net.minecraft.world.WorldServer; import noppes.npcs.CustomNpcs; import noppes.npcs.NoppesUtilServer; import noppes.npcs.controllers.*; +import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.items.ItemScripted; import noppes.npcs.containers.ContainerNpcInterface; import noppes.npcs.entity.EntityCustomNpc; @@ -349,6 +350,6 @@ public class NpcAPI extends AbstractNpcAPI { } public ISkinOverlay createSkinOverlay(String texture) { - return new ScriptSkinOverlay(texture); + return new SkinOverlayData(texture); } } diff --git a/src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java b/src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java deleted file mode 100644 index 40127d044..000000000 --- a/src/main/java/noppes/npcs/scripted/ScriptSkinOverlay.java +++ /dev/null @@ -1,89 +0,0 @@ -package noppes.npcs.scripted; - -import noppes.npcs.scripted.interfaces.ISkinOverlay; - -public class ScriptSkinOverlay implements ISkinOverlay { - public String texture; - public boolean glow; - public float alpha = 1.0F; - public float size = 1.0F; - - public float speedX = 0.0F; - public float speedY = 0.0F; - - public float scaleX = 1.0F; - public float scaleY = 1.0F; - - public float offsetX = 0.0F; - public float offsetY = 0.0F; - public float offsetZ = 0.0F; - - public ScriptSkinOverlay(String texture) { - this.texture = texture; - } - - public void setTexture(String texture) { - this.texture = texture; - } - public String getTexture() { - return texture; - } - - public void setGlow(boolean glow) { - this.glow = glow; - } - public boolean getGlow() { - return glow; - } - - public void setAlpha(float alpha) { - this.alpha = alpha; - } - public float getAlpha() { - return alpha; - } - - public void setSize(float size) { - this.size = size; - } - public float getSize() { - return size; - } - - public void setScale(float scaleX, float scaleY) { - this.scaleX = scaleX; - this.scaleY = scaleY; - } - public float getScaleX() { - return scaleX; - } - public float getScaleY() { - return scaleY; - } - - public void setSpeed(float speedX, float speedY) { - this.speedX = speedX; - this.speedY = speedY; - } - public float getSpeedX() { - return speedX; - } - public float getSpeedY() { - return speedY; - } - - public void setOffset(float offsetX, float offsetY, float offsetZ) { - this.offsetX = offsetX; - this.offsetY = offsetY; - this.offsetZ = offsetZ; - } - public float getOffsetX() { - return offsetX; - } - public float getOffsetY() { - return offsetY; - } - public float getOffsetZ() { - return offsetZ; - } -} diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index da46cd42b..6565a496f 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -1,19 +1,14 @@ package noppes.npcs.scripted.entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.ResourceLocation; import noppes.npcs.CustomNpcs; import noppes.npcs.NoppesUtilServer; -import noppes.npcs.Server; import noppes.npcs.constants.*; import noppes.npcs.controllers.Line; import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.ScriptFaction; -import noppes.npcs.scripted.ScriptSkinOverlay; import noppes.npcs.scripted.interfaces.ISkinOverlay; import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; import noppes.npcs.scripted.interfaces.entity.IPlayer; @@ -41,7 +36,6 @@ import noppes.npcs.scripted.NpcAPI; import noppes.npcs.util.ValueUtil; import java.util.ArrayList; -import java.util.HashMap; import java.util.UUID; public class ScriptNpc extends ScriptLiving implements ICustomNpc { @@ -1109,16 +1103,12 @@ public class ScriptNpc extends ScriptLiving imp if (!npc.display.skinOverlays.containsKey(0)) return ""; - return npc.display.skinOverlays.get(0).directory; + return npc.display.skinOverlays.get(0).getTexture(); } public void setSkinOverlay(int id, ISkinOverlay overlay) { if (overlay != null) { - npc.display.skinOverlays.put(id, new SkinOverlayData( - overlay.getTexture(),overlay.getGlow(),overlay.getAlpha(),overlay.getSize(), - overlay.getSpeedX(),overlay.getSpeedY(),overlay.getScaleX(),overlay.getScaleY(), - overlay.getOffsetX(),overlay.getOffsetY(),overlay.getOffsetZ() - )); + npc.display.skinOverlays.put(id, overlay); } } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java b/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java index e516cbc8c..18e8d3951 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java @@ -1,5 +1,7 @@ package noppes.npcs.scripted.interfaces; +import net.minecraft.util.ResourceLocation; + public interface ISkinOverlay { void setTexture(String texture); @@ -27,4 +29,7 @@ public interface ISkinOverlay { float getOffsetX(); float getOffsetY(); float getOffsetZ(); + + ResourceLocation getLocation(); + void setLocation(ResourceLocation location); } From 648206f5bae665a4cfa44ff87b128e9800ac4a5e Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 17 May 2022 04:53:41 -0500 Subject: [PATCH 54/75] Updated interfaces to have the new skin overlay functions. --- .../npcs/scripted/interfaces/entity/ICustomNpc.java | 13 +++++++++++++ .../npcs/scripted/interfaces/entity/IPlayer.java | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java index 8b9efff78..43e3f1dc6 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java @@ -7,6 +7,7 @@ package noppes.npcs.scripted.interfaces.entity; import net.minecraft.entity.EntityCreature; import noppes.npcs.scripted.ScriptFaction; +import noppes.npcs.scripted.interfaces.ISkinOverlay; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.ITimers; import noppes.npcs.scripted.roles.*; @@ -718,6 +719,14 @@ public interface ICustomNpc extends IEntityLiving { double getFlyGravity(double flyGravity); + void setFlyHeightLimit(int flyHeightLimit); + + int getFlyHeightLimit(int flyHeightLimit); + + void limitFlyHeight(boolean limit); + + boolean isFlyHeightLimited(boolean limit); + void setSpeed(int speed); int getSpeed(); @@ -738,6 +747,10 @@ public interface ICustomNpc extends IEntityLiving { String getOverlayTexture(); + void setSkinOverlay(int id, ISkinOverlay overlay); + + void removeSkinOverlay(int id); + void setCollisionType(int type); int getCollisionType(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java index 212b6280f..dec675a23 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java @@ -225,5 +225,9 @@ public interface IPlayer extends IEntityLivingBase void closeOverlay(int id); + void setSkinOverlay(int id, ISkinOverlay overlay); + + void removeSkinOverlay(int id); + IQuest[] getFinishedQuests(); } From fd1aa404564f9195e00bc2611232a0da08aca928 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 17 May 2022 05:24:57 -0500 Subject: [PATCH 55/75] Added some documentation to a few interfaces for the javadoc. --- .../noppes/npcs/scripted/ScriptBlock.java | 8 +-- .../npcs/scripted/interfaces/IBlock.java | 66 +++++++++++++++++-- .../npcs/scripted/interfaces/IContainer.java | 32 ++++++++- .../scripted/interfaces/IDamageSource.java | 16 +++++ 4 files changed, 111 insertions(+), 11 deletions(-) diff --git a/src/main/java/noppes/npcs/scripted/ScriptBlock.java b/src/main/java/noppes/npcs/scripted/ScriptBlock.java index d7ab06245..8c4f25673 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptBlock.java +++ b/src/main/java/noppes/npcs/scripted/ScriptBlock.java @@ -62,8 +62,8 @@ public class ScriptBlock implements IBlock { return this.block.isAir(this.world.getMCWorld(), getX(), getY(), getZ()); } - public ScriptBlock setBlock(String name) { - Block block = (Block)Block.blockRegistry.getObject(new ResourceLocation(name)); + public ScriptBlock setBlock(String blockName) { + Block block = (Block)Block.blockRegistry.getObject(new ResourceLocation(blockName)); if(block == null) { return this; } else { @@ -113,11 +113,11 @@ public class ScriptBlock implements IBlock { return this.tile != null; } - public ScriptTileEntity getTileEntity() { + public ITileEntity getTileEntity() { return new ScriptTileEntity(this.tile); } - public void setTileEntity(ScriptTileEntity tileEntity){ + public void setTileEntity(ITileEntity tileEntity){ world.setTileEntity(pos.getX(),pos.getY(), pos.getZ(),tileEntity); this.tile = tileEntity.getMCTileEntity(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java b/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java index 561ddca1c..3dfa5a466 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java @@ -7,7 +7,6 @@ package noppes.npcs.scripted.interfaces; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; -import noppes.npcs.scripted.ScriptTileEntity; public interface IBlock { int getX(); @@ -16,35 +15,92 @@ public interface IBlock { int getZ(); + /** + * + * @return Returns an IPos object with the block's XYZ position. + */ IPos getPos(); + /** + * + * @return Returns the block name as it appears in the block registry. Return example: "minecraft:stone" + */ String getName(); + /** + * Deletes the block, setting it to air. + */ void remove(); boolean isAir(); - IBlock setBlock(String var1); + /** + * + * @param blockName The name of the block to be set in place of this block. + * @return Returns the new block set in place of this block as an IBlock object. + */ + IBlock setBlock(String blockName); - IBlock setBlock(IBlock var1); + /** + * + * @param block Input IBlock object to replace this block. + * @return Returns the new block set in place of the previous block. + */ + IBlock setBlock(IBlock block); + /** + * + * @return Returns true if the block can contain items like a chest does. + */ boolean isContainer(); + /** + * + * @return Returns the container object of this block. If this block is not a container, an exception will be thrown. + */ IContainer getContainer(); + /** + * + * @return Returns an IWorld object of the world this block is in. + */ IWorld getWorld(); + /** + * + * @return Returns true if this block has a tile entity. Blocks with custom data like signs, player skulls, chests, etc. will have tile entities. + */ boolean hasTileEntity(); - ScriptTileEntity getTileEntity(); + /** + * + * @return Returns an ITileEntity object which can modify this block's tile entity. + */ + ITileEntity getTileEntity(); - void setTileEntity(ScriptTileEntity tileEntity); + /** + * + * @param tileEntity Replaces this block's tile entity based on the data given by this parameter. + */ + void setTileEntity(ITileEntity tileEntity); + /** + * + * @return Returns a non-script, obfuscated MC object for the block's tile entity. + */ TileEntity getMCTileEntity(); + /** + * + * @return Returns a non-script, obfuscated MC block object. + */ Block getMCBlock(); String getDisplayName(); + /** + * + * @return Returns an INbt object which can modify the block's tile entity's NBT data. + */ INbt getTileEntityNBT(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java b/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java index 47f6d5358..e639dabbe 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java @@ -13,18 +13,46 @@ import noppes.npcs.scripted.interfaces.item.IItemStack; public interface IContainer { int getSize(); - IItemStack getSlot(int var1); + IItemStack getSlot(int slot); + /** + * + * @param slot The slot to be replaced + * @param item The item replacing the previous item in that slot, as an IItemStack object + */ void setSlot(int slot, IItemStack item); + /** + * + * @return Returns a non-script, obfuscated MC inventory object. + */ IInventory getMCInventory(); + /** + * + * @return Returns a non-script, obfuscated MC container object. + */ Container getMCContainer(); - int count(IItemStack var1, boolean var2, boolean var3); + /** + * + * @param itemStack The item stack to be searched in the container + * @param ignoreDamage Whether damage should be ignored when searching + * @param ignoreNBT Whether NBT values should be ignored when searching + * @return Returns the amount of the item stack found, based on the flags given above. + */ + int count(IItemStack itemStack, boolean ignoreDamage, boolean ignoreNBT); + /** + * + * @return Returns a list of all item stacks in the container as a list of IItemStack objects. + */ IItemStack[] getItems(); + /** + * + * @return Returns true if this container belongs to a Custom GUI. + */ boolean isCustomGUI(); void detectAndSendChanges(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java b/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java index 529db409c..838b66699 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java @@ -9,15 +9,31 @@ import net.minecraft.util.DamageSource; import noppes.npcs.scripted.interfaces.entity.IEntity; public interface IDamageSource { + /** + * + * @return Returns the damage type of the damage source as a string. Ex: "lava", "explosion", "magic", "outOfWorld", etc. + */ String getType(); boolean isUnblockable(); boolean isProjectile(); + /** + * + * @return Returns the entity source of where the damage source originated. If a player was shot by an arrow from a skeleton, this would return an IEntity object of the skeleton. + */ IEntity getTrueSource(); + /** + * + * @return Returns the entity source of where the damage source originated. If a player was shot by an arrow from a skeleton, this would return an IEntity object of the arrow. + */ IEntity getImmediateSource(); + /** + * + * @return Returns a non-script, obfuscated MC damage source object. + */ DamageSource getMCDamageSource(); } From 57ce6b7a26b4d202c74583a96622cfeba48d8428 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 17 May 2022 05:26:45 -0500 Subject: [PATCH 56/75] Removed plenty of unnecessary setters from ScriptParticle. --- .../noppes/npcs/scripted/ScriptParticle.java | 48 ------------------- .../npcs/scripted/interfaces/IParticle.java | 24 ---------- 2 files changed, 72 deletions(-) diff --git a/src/main/java/noppes/npcs/scripted/ScriptParticle.java b/src/main/java/noppes/npcs/scripted/ScriptParticle.java index 07a0b3209..dc3e3f862 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptParticle.java +++ b/src/main/java/noppes/npcs/scripted/ScriptParticle.java @@ -283,18 +283,6 @@ public class ScriptParticle implements IParticle { this.HEXColorRate = HEXColorRate; this.HEXColorStart = HEXColorStart; } - public void setHEXColor1(int HEXColor) { - this.HEXColor = HEXColor; - } - public void setHEXColor2(int HEXColor2) { - this.HEXColor2 = HEXColor2; - } - public void setHEXColorRate(float HEXColorRate) { - this.HEXColorRate = HEXColorRate; - } - public void setHEXColorStart(int HEXColorStart) { - this.HEXColorStart = HEXColorStart; - } public void setAlpha(float alpha1, float alpha2, float alphaRate, int alphaRateStart){ this.alpha1 = alpha1; @@ -302,18 +290,6 @@ public class ScriptParticle implements IParticle { this.alphaRate = alphaRate; this.alphaRateStart = alphaRateStart; } - public void setAlpha1(float alpha1) { - this.alpha1 = alpha1; - } - public void setAlpha2(float alpha2) { - this.alpha2 = alpha2; - } - public void setAlphaRate(float alphaRate) { - this.alphaRate = alphaRate; - } - public void setAlphaRateStart(int alphaRateStart) { - this.alphaRateStart = alphaRateStart; - } public void setScale(float scale1, float scale2, float scaleRate, int scaleRateStart){ this.scale1 = scale1; @@ -321,18 +297,6 @@ public class ScriptParticle implements IParticle { this.scaleRate = scaleRate; this.scaleRateStart = scaleRateStart; } - public void setScale1(float scale1) { - this.scale1 = scale1; - } - public void setScale2(float scale2) { - this.scale2 = scale2; - } - public void setScaleRate(float scaleRate) { - this.scaleRate = scaleRate; - } - public void setScaleRateStart(int scaleRateStart) { - this.scaleRateStart = scaleRateStart; - } public void setRotationX(float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart){ this.rotationX1 = rotationX1; @@ -340,10 +304,6 @@ public class ScriptParticle implements IParticle { this.rotationXRate = rotationXRate; this.rotationXRateStart = rotationXRateStart; } - public void setRotationX1(float rotationX1) {this.rotationX1 = rotationX1;} - public void setRotationX2(float rotationX2) {this.rotationX2 = rotationX2;} - public void setRotationXRate(float rotationXRate) {this.rotationXRate = rotationXRate;} - public void setRotationXRateStart(int rotationXRateStart) {this.rotationXRateStart = rotationXRateStart;} public void setRotationY(float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart){ this.rotationY1 = rotationY1; @@ -351,10 +311,6 @@ public class ScriptParticle implements IParticle { this.rotationYRate = rotationYRate; this.rotationYRateStart = rotationYRateStart; } - public void setRotationY1(float rotationY1) {this.rotationY1 = rotationY1;} - public void setRotationY2(float rotationY2) {this.rotationY2 = rotationY2;} - public void setRotationYRate(float rotationYRate) {this.rotationYRate = rotationYRate;} - public void setRotationYRateStart(int rotationYRateStart) {this.rotationYRateStart = rotationYRateStart;} public void setRotationZ(float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart){ this.rotationZ1 = rotationZ1; @@ -362,8 +318,4 @@ public class ScriptParticle implements IParticle { this.rotationZRate = rotationZRate; this.rotationZRateStart = rotationZRateStart; } - public void setRotationZ1(float rotationZ1) {this.rotationZ1 = rotationZ1;} - public void setRotationZ2(float rotationZ2) {this.rotationZ2 = rotationZ2;} - public void setRotationZRate(float rotationZRate) {this.rotationZRate = rotationZRate;} - public void setRotationZRateStart(int rotationZRateStart) {this.rotationZRateStart = rotationZRateStart;} } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java b/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java index 1929e048d..2a1d51513 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java @@ -96,39 +96,15 @@ public interface IParticle { void setGravity(float gravity); void setHEXColor(int HEXColor, int HEXColor2, float HEXColorRate, int HEXColorStart); - void setHEXColor1(int HEXColor); - void setHEXColor2(int HEXColor2); - void setHEXColorRate(float HEXColorRate); - void setHEXColorStart(int HEXColorStart); void setAlpha(float alpha1, float alpha2, float alphaRate, int alphaRateStart); - void setAlpha1(float alpha1); - void setAlpha2(float alpha2); - void setAlphaRate(float alphaRate); - void setAlphaRateStart(int alphaRateStart); void setScale(float scale1, float scale2, float scaleRate, int scaleRateStart); - void setScale1(float scale1); - void setScale2(float scale2); - void setScaleRate(float scaleRate); - void setScaleRateStart(int scaleRateStart); void setRotationX(float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart); - void setRotationX1(float rotationX1); - void setRotationX2(float rotationX2); - void setRotationXRate(float rotationXRate); - void setRotationXRateStart(int rotationXRateStart); void setRotationY(float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart); - void setRotationY1(float rotationY1); - void setRotationY2(float rotationY2); - void setRotationYRate(float rotationYRate); - void setRotationYRateStart(int rotationYRateStart); void setRotationZ(float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart); - void setRotationZ1(float rotationZ1); - void setRotationZ2(float rotationZ2); - void setRotationZRate(float rotationZRate); - void setRotationZRateStart(int rotationZRateStart); } From af4b4679317e8dbd6166065ce5eec5dfcef8cfe6 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 17 May 2022 05:35:08 -0500 Subject: [PATCH 57/75] Updated the arrangement of interfaces and functions of ScriptParticle to be more readable for future javadoc filling. --- .../noppes/npcs/scripted/ScriptParticle.java | 182 +++++++----------- .../npcs/scripted/interfaces/IParticle.java | 62 ++---- 2 files changed, 93 insertions(+), 151 deletions(-) diff --git a/src/main/java/noppes/npcs/scripted/ScriptParticle.java b/src/main/java/noppes/npcs/scripted/ScriptParticle.java index dc3e3f862..5a70d91dc 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptParticle.java +++ b/src/main/java/noppes/npcs/scripted/ScriptParticle.java @@ -101,6 +101,30 @@ public class ScriptParticle implements IParticle { ); } + public void setFacePlayer(boolean facePlayer) { this.facePlayer = facePlayer; } + public boolean getFacePlayer() { return facePlayer; } + + public String getDirectory() { + return directory; + } + public void setDirectory(String directory) { + this.directory = directory; + } + + public void setAmount(int amount) { + this.amount = amount; + } + public int getAmount() { + return amount; + } + + public void setMaxAge(int maxAge) { + this.maxAge = maxAge; + } + public int getMaxAge() { + return maxAge; + } + public void setSize(int width, int height){ this.width = width; this.height = height; @@ -121,39 +145,16 @@ public class ScriptParticle implements IParticle { this.animStart = animStart; this.animEnd = animEnd; } - public void setAnimRate(int animRate) { this.animRate = animRate; } public int getAnimRate() { return animRate; } - public void setAnimLoop(boolean animLoop) { this.animLoop = animLoop; } public boolean getAnimLoop() { return animLoop; } - public void setAnimStart(int animStart) { this.animStart = animStart; } public int getAnimStart() { return animStart; } - public void setAnimEnd(int animEnd) { this.animEnd = animEnd; } public int getAnimEnd() { return animEnd; } - public boolean getFacePlayer() { return facePlayer; } - public void setFacePlayer(boolean facePlayer) { this.facePlayer = facePlayer; } - - public String getDirectory() { - return directory; + public void setPosition(double x, double y, double z){ + this.x = x; + this.y = y; + this.z = z; } - - @Deprecated - public void setHEXColor(int HEXColor) { - this.HEXColor = HEXColor; - } - @Deprecated - public int getHEXColor() { - return HEXColor; - } - - public int getAmount() { - return amount; - } - - public int getMaxAge() { - return maxAge; - } - public double getX() { return x; } @@ -164,6 +165,12 @@ public class ScriptParticle implements IParticle { return z; } + public void setMotion(double motionX, double motionY, double motionZ, float gravity){ + this.motionX = motionX; + this.motionY = motionY; + this.motionZ = motionZ; + this.gravity = gravity; + } public double getMotionX() { return motionX; } @@ -177,6 +184,12 @@ public class ScriptParticle implements IParticle { return gravity; } + public void setHEXColor(int HEXColor, int HEXColor2, float HEXColorRate, int HEXColorStart) { + this.HEXColor = HEXColor; + this.HEXColor2 = HEXColor2; + this.HEXColorRate = HEXColorRate; + this.HEXColorStart = HEXColorStart; + } public int getHEXColor1() { return HEXColor; } @@ -190,6 +203,12 @@ public class ScriptParticle implements IParticle { return HEXColorStart; } + public void setAlpha(float alpha1, float alpha2, float alphaRate, int alphaRateStart){ + this.alpha1 = alpha1; + this.alpha2 = alpha2; + this.alphaRate = alphaRate; + this.alphaRateStart = alphaRateStart; + } public float getAlpha1() { return alpha1; } @@ -203,6 +222,12 @@ public class ScriptParticle implements IParticle { return alphaRateStart; } + public void setScale(float scale1, float scale2, float scaleRate, int scaleRateStart){ + this.scale1 = scale1; + this.scale2 = scale2; + this.scaleRate = scaleRate; + this.scaleRateStart = scaleRateStart; + } public float getScale1() { return scale1; } @@ -216,94 +241,16 @@ public class ScriptParticle implements IParticle { return scaleRateStart; } - public float getRotationX1() {return rotationX1;} - public float getRotationX2() {return rotationX2;} - public float getRotationXRate() {return rotationXRate;} - public int getRotationXRateStart() {return rotationXRateStart;} - - public float getRotationY1() {return rotationY1;} - public float getRotationY2() {return rotationY2;} - public float getRotationYRate() {return rotationYRate;} - public int getRotationYRateStart() {return rotationYRateStart;} - - public float getRotationZ1() {return rotationZ1;} - public float getRotationZ2() {return rotationZ2;} - public float getRotationZRate() {return rotationZRate;} - public int getRotationZRateStart() {return rotationZRateStart;} - - public void setDirectory(String directory) { - this.directory = directory; - } - - public void setAmount(int amount) { - this.amount = amount; - } - - public void setMaxAge(int maxAge) { - this.maxAge = maxAge; - } - - public void setPosition(double x, double y, double z){ - this.x = x; - this.y = y; - this.z = z; - } - public void setX(double x) { - this.x = x; - } - public void setY(double y) { - this.y = y; - } - public void setZ(double z) { - this.z = z; - } - - public void setMotion(double motionX, double motionY, double motionZ, float gravity){ - this.motionX = motionX; - this.motionY = motionY; - this.motionZ = motionZ; - this.gravity = gravity; - } - public void setMotionX(double motionX) { - this.motionX = motionX; - } - public void setMotionY(double motionY) { - this.motionY = motionY; - } - public void setMotionZ(double motionZ) { - this.motionZ = motionZ; - } - public void setGravity(float gravity) { - this.gravity = gravity; - } - - public void setHEXColor(int HEXColor, int HEXColor2, float HEXColorRate, int HEXColorStart) { - this.HEXColor = HEXColor; - this.HEXColor2 = HEXColor2; - this.HEXColorRate = HEXColorRate; - this.HEXColorStart = HEXColorStart; - } - - public void setAlpha(float alpha1, float alpha2, float alphaRate, int alphaRateStart){ - this.alpha1 = alpha1; - this.alpha2 = alpha2; - this.alphaRate = alphaRate; - this.alphaRateStart = alphaRateStart; - } - - public void setScale(float scale1, float scale2, float scaleRate, int scaleRateStart){ - this.scale1 = scale1; - this.scale2 = scale2; - this.scaleRate = scaleRate; - this.scaleRateStart = scaleRateStart; - } - public void setRotationX(float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart){ this.rotationX1 = rotationX1; this.rotationX2 = rotationX2; this.rotationXRate = rotationXRate; this.rotationXRateStart = rotationXRateStart; } + public float getRotationX1() {return rotationX1;} + public float getRotationX2() {return rotationX2;} + public float getRotationXRate() {return rotationXRate;} + public int getRotationXRateStart() {return rotationXRateStart;} public void setRotationY(float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart){ this.rotationY1 = rotationY1; @@ -311,6 +258,10 @@ public class ScriptParticle implements IParticle { this.rotationYRate = rotationYRate; this.rotationYRateStart = rotationYRateStart; } + public float getRotationY1() {return rotationY1;} + public float getRotationY2() {return rotationY2;} + public float getRotationYRate() {return rotationYRate;} + public int getRotationYRateStart() {return rotationYRateStart;} public void setRotationZ(float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart){ this.rotationZ1 = rotationZ1; @@ -318,4 +269,17 @@ public class ScriptParticle implements IParticle { this.rotationZRate = rotationZRate; this.rotationZRateStart = rotationZRateStart; } + public float getRotationZ1() {return rotationZ1;} + public float getRotationZ2() {return rotationZ2;} + public float getRotationZRate() {return rotationZRate;} + public int getRotationZRateStart() {return rotationZRateStart;} + + @Deprecated + public void setHEXColor(int HEXColor) { + this.HEXColor = HEXColor; + } + @Deprecated + public int getHEXColor() { + return HEXColor; + } } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java b/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java index 2a1d51513..228495ad9 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java @@ -12,6 +12,18 @@ public interface IParticle { void spawnInWorld(ScriptWorld world, double x, double y, double z); + void setFacePlayer(boolean facePlayer); + boolean getFacePlayer(); + + void setDirectory(String directory); + String getDirectory(); + + void setAmount(int amount); + int getAmount(); + + void setMaxAge(int maxAge); + int getMaxAge(); + void setSize(int width, int height); int getWidth(); int getHeight(); @@ -21,90 +33,56 @@ public interface IParticle { int getOffsetY(); void setAnim(int animRate, boolean animLoop, int animStart, int animEnd); - void setAnimRate(int animRate); int getAnimRate(); - void setAnimLoop(boolean animLoop); boolean getAnimLoop(); - void setAnimStart(int animStart); int getAnimStart(); - void setAnimEnd(int animEnd); int getAnimEnd(); - boolean getFacePlayer(); - void setFacePlayer(boolean facePlayer); - - String getDirectory(); - - int getAmount(); - - int getMaxAge(); - + void setPosition(double x, double y, double z); double getX(); double getY(); double getZ(); + void setMotion(double motionX, double motionY, double motionZ, float gravity); double getMotionX(); double getMotionY(); double getMotionZ(); float getGravity(); + void setHEXColor(int HEXColor, int HEXColor2, float HEXColorRate, int HEXColorStart); int getHEXColor1(); int getHEXColor2(); float getHEXColorRate(); int getHEXColorStart(); + void setAlpha(float alpha1, float alpha2, float alphaRate, int alphaRateStart); float getAlpha1(); float getAlpha2(); float getAlphaRate(); int getAlphaRateStart(); + void setScale(float scale1, float scale2, float scaleRate, int scaleRateStart); float getScale1(); float getScale2(); float getScaleRate(); int getScaleRateStart(); + void setRotationX(float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart); float getRotationX1(); float getRotationX2(); float getRotationXRate(); int getRotationXRateStart(); + void setRotationY(float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart); float getRotationY1(); float getRotationY2(); float getRotationYRate(); int getRotationYRateStart(); + void setRotationZ(float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart); float getRotationZ1(); float getRotationZ2(); float getRotationZRate(); int getRotationZRateStart(); - - void setDirectory(String directory); - - void setAmount(int amount); - - void setMaxAge(int maxAge); - - void setPosition(double x, double y, double z); - void setX(double x); - void setY(double y); - void setZ(double z); - - void setMotion(double motionX, double motionY, double motionZ, float gravity); - void setMotionX(double motionX); - void setMotionY(double motionY); - void setMotionZ(double motionZ); - void setGravity(float gravity); - - void setHEXColor(int HEXColor, int HEXColor2, float HEXColorRate, int HEXColorStart); - - void setAlpha(float alpha1, float alpha2, float alphaRate, int alphaRateStart); - - void setScale(float scale1, float scale2, float scaleRate, int scaleRateStart); - - void setRotationX(float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart); - - void setRotationY(float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart); - - void setRotationZ(float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart); } From b9266c3cc50adad563e8fda958d3eb057aa31dd4 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 17 May 2022 18:02:09 -0500 Subject: [PATCH 58/75] Added plenty more documentation for the javadoc. --- .../java/noppes/npcs/scripted/NpcAPI.java | 10 +- .../noppes/npcs/scripted/ScriptBlock.java | 10 +- .../noppes/npcs/scripted/ScriptContainer.java | 4 - .../java/noppes/npcs/scripted/ScriptNbt.java | 2 +- .../noppes/npcs/scripted/ScriptParticle.java | 2 +- .../npcs/scripted/ScriptTileEntity.java | 5 +- .../noppes/npcs/scripted/ScriptWorld.java | 4 +- .../npcs/scripted/entity/ScriptPlayer.java | 2 +- .../scripted/interfaces/AbstractNpcAPI.java | 66 ++++++++- .../npcs/scripted/interfaces/IBlock.java | 24 ++-- .../npcs/scripted/interfaces/IContainer.java | 15 +- .../scripted/interfaces/IDamageSource.java | 8 +- .../noppes/npcs/scripted/interfaces/INbt.java | 124 ++++++++++++---- .../npcs/scripted/interfaces/IParticle.java | 126 ++++++++++++++++ .../noppes/npcs/scripted/interfaces/IPos.java | 135 ++++++++++++++++-- .../scripted/interfaces/ISkinOverlay.java | 35 ++++- .../npcs/scripted/interfaces/ITileEntity.java | 41 +++++- .../npcs/scripted/interfaces/ITimers.java | 65 ++++++++- .../npcs/scripted/interfaces/IWorld.java | 37 +++++ .../scripted/interfaces/entity/IPlayer.java | 2 +- 20 files changed, 623 insertions(+), 94 deletions(-) diff --git a/src/main/java/noppes/npcs/scripted/NpcAPI.java b/src/main/java/noppes/npcs/scripted/NpcAPI.java index 49b46d13a..4b53ebf1c 100644 --- a/src/main/java/noppes/npcs/scripted/NpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/NpcAPI.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.Map; import cpw.mods.fml.common.eventhandler.EventBus; +import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; @@ -121,12 +122,16 @@ public class NpcAPI extends AbstractNpcAPI { return new ScriptBlock(world, world.getBlock(pos.getX(),pos.getY(),pos.getZ()), pos); } + public IBlock getIBlock(World world, Block block, BlockPos pos) { + return new ScriptBlock(world, block, pos); + } + public IBlock getIBlock(World world, int x, int y, int z) { return new ScriptBlock(world, world.getBlock(x, y, z), new BlockPos(x,y,z)); } - public INbt getINbt(NBTTagCompound compound) { - return compound == null?new ScriptNbt(new NBTTagCompound()):new ScriptNbt(compound); + public INbt getINbt(NBTTagCompound nbtTagCompound) { + return nbtTagCompound == null?new ScriptNbt(new NBTTagCompound()):new ScriptNbt(nbtTagCompound); } public INbt stringToNbt(String str) { @@ -272,6 +277,7 @@ public class NpcAPI extends AbstractNpcAPI { //if(!world.getMCWorld().isRemote) NoppesUtilServer.runCommand(world.getMCWorld(), "API", command); } + public String getRandomName(int dictionary, int gender) { return CustomNpcs.MARKOV_GENERATOR[dictionary].fetch(gender); } diff --git a/src/main/java/noppes/npcs/scripted/ScriptBlock.java b/src/main/java/noppes/npcs/scripted/ScriptBlock.java index 8c4f25673..9747d4aa5 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptBlock.java +++ b/src/main/java/noppes/npcs/scripted/ScriptBlock.java @@ -18,7 +18,7 @@ import noppes.npcs.scripted.interfaces.*; import noppes.npcs.util.LRUHashMap; public class ScriptBlock implements IBlock { - private static final Map blockCache = new LRUHashMap(400); + private static final Map blockCache = new LRUHashMap(400); protected final IWorld world; protected final Block block; protected final BlockPos pos; @@ -62,19 +62,19 @@ public class ScriptBlock implements IBlock { return this.block.isAir(this.world.getMCWorld(), getX(), getY(), getZ()); } - public ScriptBlock setBlock(String blockName) { + public IBlock setBlock(String blockName) { Block block = (Block)Block.blockRegistry.getObject(new ResourceLocation(blockName)); if(block == null) { return this; } else { this.world.getMCWorld().setBlock(getX(),getY(),getZ(),block); - return new ScriptBlock(this.world.getMCWorld(), block, this.pos); + return NpcAPI.Instance().getIBlock(world.getMCWorld(), block, new BlockPos(getX(),getY(),getZ())); } } - public ScriptBlock setBlock(IBlock block) { + public IBlock setBlock(IBlock block) { this.world.getMCWorld().setBlock(getX(),getY(),getZ(),block.getMCBlock()); - return new ScriptBlock(this.world.getMCWorld(), block.getMCBlock(), this.pos); + return NpcAPI.Instance().getIBlock(world.getMCWorld(), block.getMCBlock(), new BlockPos(getX(),getY(),getZ())); } public boolean isContainer() { diff --git a/src/main/java/noppes/npcs/scripted/ScriptContainer.java b/src/main/java/noppes/npcs/scripted/ScriptContainer.java index 31a849364..95e1efe13 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptContainer.java +++ b/src/main/java/noppes/npcs/scripted/ScriptContainer.java @@ -94,10 +94,6 @@ public class ScriptContainer implements IContainer { container.detectAndSendChanges(); } - public void putStackInSlot(int slot, IItemStack itemStack){ - container.putStackInSlot(slot,itemStack.getMCItemStack()); - } - public boolean isPlayerNotUsingContainer(IPlayer player){ return container.isPlayerNotUsingContainer((EntityPlayerMP) player.getMCEntity()); } diff --git a/src/main/java/noppes/npcs/scripted/ScriptNbt.java b/src/main/java/noppes/npcs/scripted/ScriptNbt.java index 968ea698d..a01544945 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptNbt.java +++ b/src/main/java/noppes/npcs/scripted/ScriptNbt.java @@ -200,7 +200,7 @@ public class ScriptNbt implements INbt { } public boolean isEqual(INbt nbt) { - return nbt == null?false:this.compound.equals(nbt.getMCNBT()); + return nbt != null && this.compound.equals(nbt.getMCNBT()); } public void clear() { diff --git a/src/main/java/noppes/npcs/scripted/ScriptParticle.java b/src/main/java/noppes/npcs/scripted/ScriptParticle.java index 5a70d91dc..2d8481c6c 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptParticle.java +++ b/src/main/java/noppes/npcs/scripted/ScriptParticle.java @@ -17,7 +17,7 @@ public class ScriptParticle implements IParticle { private double x = 0,y = 0,z = 0; private double motionX = 0,motionY = 0,motionZ = 0; private float gravity = 0; - private float scale1 = 1.0f,scale2 = 1.0f,scaleRate = 0.0f; + private float scale1 = 20.0f,scale2 = 20.0f,scaleRate = 0.0f; private float alpha1 = 1.0f,alpha2 = 1.0f,alphaRate = 0.0f; private int scaleRateStart = 0, alphaRateStart = 0; diff --git a/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java b/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java index 9aecc2268..e0d963d5e 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java +++ b/src/main/java/noppes/npcs/scripted/ScriptTileEntity.java @@ -4,6 +4,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; +import noppes.npcs.scripted.interfaces.IBlock; import noppes.npcs.scripted.interfaces.INbt; import noppes.npcs.scripted.interfaces.ITileEntity; @@ -32,8 +33,8 @@ public class ScriptTileEntity implements ITileEntity { return this.tileEntity.getDistanceFrom(x,y,z); } - public ScriptBlock getBlockType(){ - return new ScriptBlock(tileEntity.getWorldObj(), tileEntity.getBlockType(), new BlockPos(tileEntity.xCoord,tileEntity.yCoord,tileEntity.zCoord)); + public IBlock getBlockType(){ + return NpcAPI.Instance().getIBlock(tileEntity.getWorldObj(), tileEntity.getBlockType(), new BlockPos(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord)); } public boolean isInvalid(){ diff --git a/src/main/java/noppes/npcs/scripted/ScriptWorld.java b/src/main/java/noppes/npcs/scripted/ScriptWorld.java index eebbcb8f7..078361150 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptWorld.java +++ b/src/main/java/noppes/npcs/scripted/ScriptWorld.java @@ -71,7 +71,7 @@ public class ScriptWorld implements IWorld { Block block = world.getBlock(x, y, z); if(block == null || block.isAir(world, x, y, z)) return null; - return new ScriptBlock(world, block, new BlockPos(x,y,z)); + return NpcAPI.Instance().getIBlock(world, block, new BlockPos(x,y,z)); } public boolean isBlockFreezable(int x, int y, int z){ @@ -103,7 +103,7 @@ public class ScriptWorld implements IWorld { for (y = 63; !world.isAirBlock(x, y + 1, z); ++y) {;} Block block = world.getBlock(x, y, z); - return new ScriptBlock(world, block, new BlockPos(x,y,z)); + return NpcAPI.Instance().getIBlock(world, block, new BlockPos(x,y,z)); } public int getHeightValue(int x, int z){ diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index 5fe85514b..7a6c8d193 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -388,7 +388,7 @@ public class ScriptPlayer extends ScriptLivingBase return NpcAPI.Instance().getIEntity(player.dropOneItem(dropStack)); } - public boolean canHarvestBlock(ScriptBlock block){ + public boolean canHarvestBlock(IBlock block){ return player.canHarvestBlock(block.getMCBlock()); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/AbstractNpcAPI.java b/src/main/java/noppes/npcs/scripted/interfaces/AbstractNpcAPI.java index 611848222..939341e73 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/AbstractNpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/AbstractNpcAPI.java @@ -9,6 +9,7 @@ import java.io.File; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.eventhandler.EventBus; +import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.Container; @@ -32,6 +33,10 @@ import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay; import noppes.npcs.scripted.overlay.ScriptOverlay; +/** + * This object stores functions available to all scripting handlers through the "API" keyword. + * + */ public abstract class AbstractNpcAPI { private static AbstractNpcAPI instance = null; @@ -50,12 +55,18 @@ public abstract class AbstractNpcAPI { public abstract ICustomNpc createNPC(World var1); + /** + * + * Spawns a new NPC in the world at the given coordinates and returns an ICustomNpc object of it. + */ public abstract ICustomNpc spawnNPC(World var1, int var2, int var3, int var4); public abstract IEntity getIEntity(Entity var1); public abstract IBlock getIBlock(World var1, BlockPos var2); + public abstract IBlock getIBlock(World world, Block block, BlockPos pos); + public abstract IBlock getIBlock(World world, int x, int y, int z); public abstract IContainer getIContainer(IInventory var1); @@ -101,9 +112,28 @@ public abstract class AbstractNpcAPI { public abstract void executeCommand(IWorld var1, String var2); - public abstract String getRandomName(int var1, int var2); + /** + * Generates a new name as a String using the Markov name generator. + * + * @param dictionary An integer representing which dictionary to use: + * 0: Roman + * 1: Japanese + * 2: Slavic + * 3: Welsh + * 4: Saami + * 5: Old Norse + * 6: Ancient Greek + * 7: Aztec + * 8: CustomNPCs Classic + * 9: Spanish + * @param gender The gender of the name: + * 0: Random + * 1: Male + * 2: Female + */ + public abstract String getRandomName(int dictionary, int gender); - public abstract INbt getINbt(NBTTagCompound entityData); + public abstract INbt getINbt(NBTTagCompound nbtTagCompound); public abstract IPlayer[] getAllServerPlayers(); @@ -113,14 +143,30 @@ public abstract class AbstractNpcAPI { public abstract void playSoundToNearExcept(IPlayer player, String sound, float volume, float pitch); + /** + * + * @return Returns the server's Message of The Day. + */ public abstract String getMOTD(); + /** + * @param motd The server's new Message of The Day. + */ public abstract void setMOTD(String motd); + /** + * + * @return A new IParticle object initialized with the given texture. + */ public abstract IParticle createParticle(String directory); + @Deprecated public abstract IParticle createEntityParticle(String directory); + /** + * + * @return The uptime of the server in MC ticks. + */ public abstract int getServerTime(); public abstract boolean arePlayerScriptsEnabled(); @@ -135,9 +181,25 @@ public abstract class AbstractNpcAPI { public abstract void enableGlobalNPCScripts(boolean enable); + /** + * + * @param id The id of the custom GUI. + * @param width The width of the GUI in pixels. + * @param height The height of the GUI in pixels. + * @param pauseGame Whether the GUI pauses the game or not. + * @return A new ICustomGui object with the given attributes. + */ public abstract ICustomGui createCustomGui(int id, int width, int height, boolean pauseGame); + /** + * + * @return A new ICustomOverlay overlay object with the given ID. + */ public abstract ICustomOverlay createCustomOverlay(int id); + /** + * + * @return A new ISkinOverlay object initialized with the given texture. + */ public abstract ISkinOverlay createSkinOverlay(String texture); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java b/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java index 3dfa5a466..c3f99a78b 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java @@ -17,13 +17,13 @@ public interface IBlock { /** * - * @return Returns an IPos object with the block's XYZ position. + * @return An IPos object with the block's XYZ position. */ IPos getPos(); /** * - * @return Returns the block name as it appears in the block registry. Return example: "minecraft:stone" + * @return The block name as it appears in the block registry. Return example: "minecraft:stone" */ String getName(); @@ -37,44 +37,44 @@ public interface IBlock { /** * * @param blockName The name of the block to be set in place of this block. - * @return Returns the new block set in place of this block as an IBlock object. + * @return The new block set in place of this block as an IBlock object. */ IBlock setBlock(String blockName); /** * * @param block Input IBlock object to replace this block. - * @return Returns the new block set in place of the previous block. + * @return The new block set in place of the previous block. */ IBlock setBlock(IBlock block); /** * - * @return Returns true if the block can contain items like a chest does. + * @return True if the block can contain items like a chest does. */ boolean isContainer(); /** * - * @return Returns the container object of this block. If this block is not a container, an exception will be thrown. + * @return The container object of this block. If this block is not a container, an exception will be thrown. */ IContainer getContainer(); /** * - * @return Returns an IWorld object of the world this block is in. + * @return An IWorld object of the world this block is in. */ IWorld getWorld(); /** * - * @return Returns true if this block has a tile entity. Blocks with custom data like signs, player skulls, chests, etc. will have tile entities. + * @return True if this block has a tile entity. Blocks with custom data like signs, player skulls, chests, etc. will have tile entities. */ boolean hasTileEntity(); /** * - * @return Returns an ITileEntity object which can modify this block's tile entity. + * @return An ITileEntity object which can modify this block's tile entity. */ ITileEntity getTileEntity(); @@ -86,13 +86,13 @@ public interface IBlock { /** * - * @return Returns a non-script, obfuscated MC object for the block's tile entity. + * @return An obfuscated MC object for the block's tile entity. */ TileEntity getMCTileEntity(); /** * - * @return Returns a non-script, obfuscated MC block object. + * @return An obfuscated MC block object. */ Block getMCBlock(); @@ -100,7 +100,7 @@ public interface IBlock { /** * - * @return Returns an INbt object which can modify the block's tile entity's NBT data. + * @return An INbt object which can modify the block's tile entity's NBT data. */ INbt getTileEntityNBT(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java b/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java index e639dabbe..e06c5dc3a 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java @@ -24,13 +24,13 @@ public interface IContainer { /** * - * @return Returns a non-script, obfuscated MC inventory object. + * @return An obfuscated MC inventory object. */ IInventory getMCInventory(); /** * - * @return Returns a non-script, obfuscated MC container object. + * @return An obfuscated MC container object. */ Container getMCContainer(); @@ -39,25 +39,26 @@ public interface IContainer { * @param itemStack The item stack to be searched in the container * @param ignoreDamage Whether damage should be ignored when searching * @param ignoreNBT Whether NBT values should be ignored when searching - * @return Returns the amount of the item stack found, based on the flags given above. + * @return The amount of the item stack found, based on the flags given above. */ int count(IItemStack itemStack, boolean ignoreDamage, boolean ignoreNBT); /** * - * @return Returns a list of all item stacks in the container as a list of IItemStack objects. + * @return A list of all item stacks in the container as a list of IItemStack objects. */ IItemStack[] getItems(); /** * - * @return Returns true if this container belongs to a Custom GUI. + * @return True if this container belongs to a Custom GUI. */ boolean isCustomGUI(); + /** + * Sends changes to be reflected on the player's client. + */ void detectAndSendChanges(); - void putStackInSlot(int slot, IItemStack itemStack); - boolean isPlayerNotUsingContainer(IPlayer player); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java b/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java index 838b66699..eada96094 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java @@ -11,7 +11,7 @@ import noppes.npcs.scripted.interfaces.entity.IEntity; public interface IDamageSource { /** * - * @return Returns the damage type of the damage source as a string. Ex: "lava", "explosion", "magic", "outOfWorld", etc. + * @return The damage type of the damage source as a string. Ex: "lava", "explosion", "magic", "outOfWorld", etc. */ String getType(); @@ -21,19 +21,19 @@ public interface IDamageSource { /** * - * @return Returns the entity source of where the damage source originated. If a player was shot by an arrow from a skeleton, this would return an IEntity object of the skeleton. + * @return The entity source of where the damage source originated. If a player was shot by an arrow from a skeleton, this would return an IEntity object of the skeleton. */ IEntity getTrueSource(); /** * - * @return Returns the entity source of where the damage source originated. If a player was shot by an arrow from a skeleton, this would return an IEntity object of the arrow. + * @return The entity source of where the damage source originated. If a player was shot by an arrow from a skeleton, this would return an IEntity object of the arrow. */ IEntity getImmediateSource(); /** * - * @return Returns a non-script, obfuscated MC damage source object. + * @return An obfuscated MC damage source object. */ DamageSource getMCDamageSource(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/INbt.java b/src/main/java/noppes/npcs/scripted/interfaces/INbt.java index 0ff2b9f77..62a4f1061 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/INbt.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/INbt.java @@ -7,70 +7,136 @@ package noppes.npcs.scripted.interfaces; import net.minecraft.nbt.NBTTagCompound; +/** + * A scripted data representation of an MC NBTTagCompound object. Using these functions modifies the compound tag + * associated with this object. Any changes made to the compound tag are made directly to its "tagMap" attribute, + * minimizing the impact of setting/getting NBT data with this object on performance. + * + * Compound tags, unlike list tags, can contain multiple types of NBT tag types. Compound tags can even + * contain compound tags inside them, and if that compound tag is accessed, an object like this one will also be returned! + * + * Every tag inside a compound tag has a -unique- "key". If you try to put another tag of the same key inside the + * compound tag, it will replace the previous tag. + * + * The types and their type as an integer are as follows: + * 1: Byte + * 2: Short + * 3: Int + * 4: Long + * 5: Float + * 6: Double + * 7: Byte array + * 8: String + * 9: Tag list + * 10: Compound + * 11: Integer array + * + */ public interface INbt { - void remove(String var1); + /** + * Returns the tag with the given key from the compound tag. + */ + void remove(String key); - boolean has(String var1); + /** + * @return True if the compound tag has a tag with the given key. + */ + boolean has(String key); - boolean getBoolean(String var1); + boolean getBoolean(String key); - void setBoolean(String var1, boolean var2); + void setBoolean(String key, boolean value); - short getShort(String var1); + short getShort(String key); - void setShort(String var1, short var2); + void setShort(String key, short value); - int getInteger(String var1); + int getInteger(String key); - void setInteger(String var1, int var2); + void setInteger(String key, int value); - byte getByte(String var1); + byte getByte(String key); - void setByte(String var1, byte var2); + void setByte(String key, byte value); - long getLong(String var1); + long getLong(String key); - void setLong(String var1, long var2); + void setLong(String key, long value); - double getDouble(String var1); + double getDouble(String key); - void setDouble(String var1, double var2); + void setDouble(String key, double value); - float getFloat(String var1); + float getFloat(String key); - void setFloat(String var1, float var2); + void setFloat(String key, float value); - String getString(String var1); + String getString(String key); - void setString(String var1, String var2); + void setString(String key, String value); - byte[] getByteArray(String var1); + byte[] getByteArray(String key); - void setByteArray(String var1, byte[] var2); + void setByteArray(String key, byte[] value); - int[] getIntegerArray(String var1); + int[] getIntegerArray(String key); - void setIntegerArray(String var1, int[] var2); + void setIntegerArray(String key, int[] value); - Object[] getList(String var1, int var2); + /** + * Returns a tag list of objects with this key in the compound tag. All the objects in the list + * will always be of the same type. + * + * @return The tag list of objects, depending on the tag type. + */ + Object[] getList(String key, int value); - int getListType(String var1); + /** + * Returns the type of the tag list with this key, as an integer. + */ + int getListType(String key); - void setList(String var1, Object[] var2); + /** + * Adds a new tag list to the compound tag with the given key. + * + * @param key The key for the list tag + * @param value The list of objects to be in the list. The type of the first element in this list becomes the tag + * list's type, and if later objects are not of this type, they will not be added. + */ + void setList(String key, Object[] value); - INbt getCompound(String var1); + INbt getCompound(String key); - void setCompound(String var1, INbt var2); + void setCompound(String key, INbt value); + /** + * + * @return A list of all the compound tag's keys. + */ String[] getKeys(); - int getType(String var1); + /** + * + * @return The type of the tag with the input key as an integer. + */ + int getType(String key); + /** + * + * @return An obfuscated MC NBTTagCompound object. + */ NBTTagCompound getMCNBT(); + /** + * + * @return A curly-bracket formatted JSON string of all the compound tag. + */ String toJsonString(); - boolean isEqual(INbt var1); + boolean isEqual(INbt nbt); + /** + * Completely clears the compound tag of all tags inside it. + */ void clear(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java b/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java index 228495ad9..ba718d2f3 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IParticle.java @@ -4,40 +4,117 @@ import noppes.npcs.NoppesUtilServer; import noppes.npcs.scripted.ScriptWorld; import noppes.npcs.scripted.interfaces.entity.IEntity; +/** + * A particle that can be spawned in the world, complete with translation, scale, rotate, and color transformations. + * (CNPC+ original!) + * + * To create a particle object: + * API.createParticle(directory); + * Then modify its attributes as you please, and call the particle's spawn functions to see it in the world. + * + * Spawning this particle in the world sends a hefty packet with all its data to the client. The particle is then + * rendered with a custom renderer based on all the given attributes. + * + * If a particle appears to not appear at first, try increasing its scale or changing its position. The entity it's + * being spawned on or a block in the world may be blocking it. + * + */ public interface IParticle { + /** + * + * @param entity Spawns this particle object on the given entity. When spawned this way, the particle will always have its origin at the entity. + */ void spawnOnEntity(IEntity entity); + /** + * + * @param world Spawns the particle in the given world, at a position corresponding to this particle's position variables. + */ void spawnInWorld(ScriptWorld world); + /** + * + * @param world Spawns the particle in the given world, at a position determined by the input parameters. + * @param x The X position the particle will spawn in the world. + * @param y The Y position the particle will spawn in the world. + * @param z The Z position the particle will spawn in the world. + */ void spawnInWorld(ScriptWorld world, double x, double y, double z); + /** + * + * @param facePlayer Whether the particle is always facing the player's camera. If this is disabled, the particle will appear to be laying flat face down on the ground if its rotation is unchanged. + */ void setFacePlayer(boolean facePlayer); boolean getFacePlayer(); + /** + * + * @param directory The directory of this particle's texture. This can be any texture in a resource pack or mod, and even a URL! + */ void setDirectory(String directory); String getDirectory(); + /** + * + * @param amount The amount of multiples of this particle to spawn in the world. Not too good looking if used, but has some edge cases where it's alright. + */ void setAmount(int amount); int getAmount(); + /** + * + * @param maxAge The maximum age this particle will be around for, in MC ticks. + */ void setMaxAge(int maxAge); int getMaxAge(); + /** + * The width and height of the particle's texture you want to render in pixels. Anything more gets cut off. + * @param width The width of the particle's texture, in pixels. + * @param height The height of the particle's texture, in pixels. + */ void setSize(int width, int height); int getWidth(); int getHeight(); + /** + * The horizontal and vertical offset of the particle's texture from the top-left, starts rendering the particle at this point. + * @param offsetX The horizontal offset, in pixels (u). + * @param offsetY The vertical offset, in pixels (v). + */ void setOffset(int offsetX, int offsetY); int getOffsetX(); int getOffsetY(); + /** + * Enables animation on the particle. Must set a custom width and height first using the setSize(width,height) function. + * Every frame of animation the particle goes through should be saved on a single image file. + * + * The renderer will read the frames of animation based on the given width and height of the particle, starting from the given X & Y offsets. + * The renderer then goes rightwards (width) pixels for every frame. Once it can't go rightwards anymore, + * the animation goes down (height) pixels, and once again keeps going rightwards if it has to. + * + * If the animation loops, once there is nowhere downward to go, the animation will start over at the X & Y offset. + * + * @param animRate The frame rate of the particle's animation, in MC ticks. (20 ticks = 1 second) + * @param animLoop Whether the animation loops or not. + * @param animStart The amount of ticks before the particle starts animating. + * @param animEnd The amount of ticks the particle is around for before it stops animating. + */ void setAnim(int animRate, boolean animLoop, int animStart, int animEnd); int getAnimRate(); boolean getAnimLoop(); int getAnimStart(); int getAnimEnd(); + /** + * + * @param x The X position from the particle's origin the particle will spawn at. + * @param y The Y position from the particle's origin the particle will spawn at. + * @param z The Z position from the particle's origin the particle will spawn at. + */ void setPosition(double x, double y, double z); double getX(); double getY(); @@ -49,36 +126,85 @@ public interface IParticle { double getMotionZ(); float getGravity(); + /** + * + * @param HEXColor The starting HEX color of the particle. + * @param HEXColor2 The ending HEX color of the particle. + * @param HEXColorRate The rate of interpolation between the two HEX colors. + * @param HEXColorStart The amount of ticks the particle is around for before its colors begin interpolating between HEXColor and HEXColor2. + */ void setHEXColor(int HEXColor, int HEXColor2, float HEXColorRate, int HEXColorStart); int getHEXColor1(); int getHEXColor2(); float getHEXColorRate(); int getHEXColorStart(); + /** + * + * @param alpha1 The starting transparency of the particle. + * @param alpha2 The ending transparency of the particle. + * @param alphaRate The rate of interpolation between the two transparency values. + * @param alphaRateStart The amount of ticks the particle is around for before its colors begin interpolating between alpha1 and alpha2. + */ void setAlpha(float alpha1, float alpha2, float alphaRate, int alphaRateStart); float getAlpha1(); float getAlpha2(); float getAlphaRate(); int getAlphaRateStart(); + /** + * + * @param scale1 The starting scale/size of the particle. + * @param scale2 The ending scale/size of the particle. + * @param scaleRate The rate of interpolation between the two scale values. + * @param scaleRateStart The amount of ticks the particle is around for before its colors begin interpolating between scale1 and scale2. + */ void setScale(float scale1, float scale2, float scaleRate, int scaleRateStart); float getScale1(); float getScale2(); float getScaleRate(); int getScaleRateStart(); + /** + * Enables rotation about the X axis. + * If the particle is set to always face the player, this axis is a constant horizontal line on the player's camera. + * + * @param rotationX1 The starting X rotation of the particle. + * @param rotationX2 The ending X rotation of the particle. + * @param rotationXRate The rate of interpolation between the two X rotation values. + * @param rotationXRateStart The amount of ticks the particle is around for before its colors begin interpolating between rotationX1 and rotationX2. + */ void setRotationX(float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart); float getRotationX1(); float getRotationX2(); float getRotationXRate(); int getRotationXRateStart(); + /** + * Enables rotation about the Y axis. + * If the particle is set to always face the player, this axis is a constant vertical line on the player's camera. + * + * @param rotationY1 The starting Y rotation of the particle. + * @param rotationY2 The ending Y rotation of the particle. + * @param rotationYRate The rate of interpolation between the two Y rotation values. + * @param rotationYRateStart The amount of ticks the particle is around for before its colors begin interpolating between rotationY1 and rotationY2. + */ void setRotationY(float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart); float getRotationY1(); float getRotationY2(); float getRotationYRate(); int getRotationYRateStart(); + /** + * Enables rotation about the Y axis. + * If the particle is set to always face the player, this axis is a constant line going into the player's camera. + * You'll be using this one most often if the particle is set to face the player. + * + * @param rotationZ1 The starting Z rotation of the particle. + * @param rotationZ2 The ending Z rotation of the particle. + * @param rotationZRate The rate of interpolation between the two Z rotation values. + * @param rotationZRateStart The amount of ticks the particle is around for before its colors begin interpolating between rotationZ1 and rotationZ2. + */ void setRotationZ(float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart); float getRotationZ1(); float getRotationZ2(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IPos.java b/src/main/java/noppes/npcs/scripted/interfaces/IPos.java index 3743f60aa..5bbd363f4 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IPos.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IPos.java @@ -14,45 +14,154 @@ public interface IPos { int getZ(); + /** + * Shifts the IPos up by 1 block and returns the new object. + * + */ IPos up(); - IPos up(int var1); + /** + * + * @param n The number of blocks to move the position up by. + * @return The new IPos object. + */ + IPos up(int n); + /** + * Shifts the IPos down by 1 block and returns the new object. + * + */ IPos down(); - IPos down(int var1); + /** + * + * @param n The number of blocks to move the position down by. + * @return The new IPos object. + */ + IPos down(int n); + /** + * Shifts the IPos north by 1 block and returns the new object. + * + */ IPos north(); - IPos north(int var1); + /** + * + * @param n The number of blocks to move the position north by. + * @return The new IPos object. + */ + IPos north(int n); + /** + * Shifts the IPos east by 1 block and returns the new object. + * + */ IPos east(); - IPos east(int var1); + /** + * + * @param n The number of blocks to move the position east by. + * @return The new IPos object. + */ + IPos east(int n); + /** + * Shifts the IPos south by 1 block and returns the new object. + * + */ IPos south(); - IPos south(int var1); + /** + * + * @param n The number of blocks to move the position south by. + * @return The new IPos object. + */ + IPos south(int n); + /** + * Shifts the IPos west by 1 block and returns the new object. + * + */ IPos west(); - IPos west(int var1); + /** + * + * @param n The number of blocks to move the position west by. + * @return The new IPos object. + */ + IPos west(int n); - IPos add(int var1, int var2, int var3); + /** + * Adds the IPos' coordinates by each of the parameters given. + * + * @param x X coordinate amount to be added + * @param y Y coordinate amount to be added + * @param z Z coordinate amount to be added + * @return The resulting IPos from the addition. + */ + IPos add(int x, int y, int z); - IPos add(IPos var1); + /** + * Directly adds the coordinates of two IPos objects and returns the resulting IPos sum. + * For example, if one IPos was represented by the coordinates (0,60,5), and another by (-10,-30,25), + * the resulting object's coordinates are (0 - 10,60 - 30,5 + 25) = (-10,30,30). + * + * @param pos The position to be added to this IPos object. + * @return The sum of the two IPos objects as a new IPos object. + */ + IPos add(IPos pos); - IPos subtract(int var1, int var2, int var3); + /** + * Subtracts the IPos' coordinates by each of the parameters given. + * + * @param x X coordinate amount to be subtracted + * @param y Y coordinate amount to be subtracted + * @param z Z coordinate amount to be subtracted + * @return The resulting IPos from the subtraction. + */ + IPos subtract(int x, int y, int z); - IPos subtract(IPos var1); + /** + * Directly subtracts the coordinates of two IPos objects and returns the resulting IPos difference. + * For example, if one IPos was represented by the coordinates (0,60,5), and another by (-10,-30,25), + * the resulting object's coordinates are (0 + 10,60 + 30,5 - 25) = (10,90,-20). + * + * @param pos The position to be subtracted from this IPos object. + * @return The difference of the two IPos objects as a new IPos object. + */ + IPos subtract(IPos pos); + /** + * Returns a normalized vector of this block's position, calculated by: + * + * + * @return The normalized vector of this block position. + */ double[] normalize(); + /** + * + * @return An obfuscated MC BlockPos object. + */ BlockPos getMCBlockPos(); - IPos offset(int var1); + /** + * Offsets the block by 1 block in the given direction and returns the resulting IPos object + * + */ + IPos offset(int direction); - IPos offset(int var1, int var2); + /** + * Offsets the block by n blocks in the given direction and returns the resulting IPos object + * + */ + IPos offset(int direction, int n); - double distanceTo(IPos var1); + /** + * + * @param pos The IPos object to calculate the distance to + * @return The distance between this IPos object and the other. + */ + double distanceTo(IPos pos); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java b/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java index 18e8d3951..637c52a7b 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ISkinOverlay.java @@ -2,34 +2,65 @@ package noppes.npcs.scripted.interfaces; import net.minecraft.util.ResourceLocation; +/** + * A skin overlay object for both NPCs and players. Several skin overlays at a time can be layered on top of each other. + * In an NPC's case, the old overlay texture is now the skin overlay with ID 0. + * + * Modifying these attributes, an overlay can be made to look like a powered creeper effect, just a new skin, or both! + */ public interface ISkinOverlay { + /** + * Sets the directory texture of the overlay. Does not support URLs. + */ void setTexture(String texture); - String getTexture(); + /** + * Sets whether this overlay glows in the dark or not. + */ void setGlow(boolean glow); - boolean getGlow(); + /** + * Sets the transparency of the overlay, from 0 to 1. + */ void setAlpha(float alpha); float getAlpha(); + /** + * Sets the size of the entire overlay when rendered on the entity. By default, overlays render slightly on top of + * the entity's model. + */ void setSize(float size); float getSize(); + /** + * Sets the texture scale of the overlay. Higher values will "zoom in" to the texture more. + */ void setScale(float scaleX, float scaleY); float getScaleX(); float getScaleY(); + /** + * Sets the "texture speed" by which the texture shifts on each render tick. Used to create a powered creeper effect! + * This does not move the entire overlay, it just moves the position at which the texture begins rendering. + */ void setSpeed(float speedX, float speedY); float getSpeedX(); float getSpeedY(); + /** + * Sets the amount in each direction by which the overlay will be offset from the entity. + */ void setOffset(float offsetX, float offsetY, float offsetZ); float getOffsetX(); float getOffsetY(); float getOffsetZ(); + /** + * + * @return The MC resource location object used to bind the overlay's texture. + */ ResourceLocation getLocation(); void setLocation(ResourceLocation location); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ITileEntity.java b/src/main/java/noppes/npcs/scripted/interfaces/ITileEntity.java index e46dc7978..d2448b23b 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ITileEntity.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ITileEntity.java @@ -5,25 +5,64 @@ import noppes.npcs.scripted.ScriptBlock; import noppes.npcs.scripted.ScriptWorld; public interface ITileEntity { + /** + * + * @return An integer representing the metadata of this block. Blocks with different states will + * return different values. For example, each stage of growth for a wheat crop will return a different value, each + * orientation of a stair block will return a different value, etc. + */ int getBlockMetadata(); + /** + * + * @return The world this tile entity is in. + */ ScriptWorld getWorld(); + /** + * + * @return An obfuscated MC tile entity object. + */ TileEntity getMCTileEntity(); + /** + * Reads an INbt compound tag, creates a tile entity based on the data, and replaces this entity with the new one. + */ void readFromNBT(INbt nbt); + /** + * @return The distance of this tile entity from the point given by the x, y, and z parameters. + */ double getDistanceFrom(double x, double y, double z); - ScriptBlock getBlockType(); + /** + * @return A new IBlock object based on this tile entity's type. + */ + IBlock getBlockType(); + /** + * + * @return True if the tile entity is invalid, false otherwise. + */ boolean isInvalid(); + /** + * Invalidates the tile entity. + */ void invalidate(); + /** + * Validates the tile entity for use. + */ void validate(); + /** + * Updates the block's tile entity to the values set in this object. + */ void updateContainingBlockInfo(); + /** + * Writes the tile entity to NBT and returns the compound tag. + */ INbt getNBT(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ITimers.java b/src/main/java/noppes/npcs/scripted/interfaces/ITimers.java index df3623e97..92d18082b 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ITimers.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ITimers.java @@ -6,29 +6,84 @@ package noppes.npcs.scripted.interfaces; public interface ITimers { - void start(int var1, int var2, boolean var3); + /** + * Adds a timer to the NPC or player with the given attributes. If this function is used and there is already a + * timer with the given ID, an exception will be thrown. + * + * @param id The id of the timer. + * @param ticks The amount of ticks before the timer ends. + * @param repeat Whether this timer repeats when it reaches its maximum amount of ticks. + */ + void start(int id, int ticks, boolean repeat); - void forceStart(int var1, int var2, boolean var3); + /** + * Adds a timer to the NPC or player with the given attributes. No exception will be thrown if there is already a + * timer with the given ID when using this function. + * + * @param id The id of the timer. + * @param ticks The amount of ticks before the timer ends. + * @param repeat Whether this timer repeats when it reaches its maximum amount of ticks. + */ + void forceStart(int id, int ticks, boolean repeat); - boolean has(int var1); + /** + * + * @return True if the set of timers contains a timer with the given id, false otherwise. + */ + boolean has(int id); - boolean stop(int var1); + /** + * Stops the timer with the given id + * + * @return True if there was a timer with the given id. + */ + boolean stop(int id); - void reset(int var1); + /** + * Resets the ticks elapsed in the timer with the given id to 0. + */ + void reset(int id); + /** + * Removes all timers. + */ void clear(); + /** + * @return The amount of ticks elapsed in the timer. + */ int ticks(int id); + /** + * Sets the amount of ticks elapsed in the timer with the given id to a different value. + * + * @param ticks The new ticks elapsed by the timer. + */ void setTicks(int id, int ticks); + /** + * @return The maximum amount of ticks the timer with the given id runs for before it stops. + */ int maxTicks(int id); + /** + * Sets the maximum amount of ticks the timer with the given id can run for before it stops. + */ void setMaxTicks(int id, int maxTicks); + /** + * @return True if the timer with the given id repeats, false otherwise. + */ boolean repeats(int id); + /** + * Sets whether the timer with the given id repeats or not. + */ void setRepeats(int id, boolean repeat); + /** + * + * @return The amount of timers in the set of timers. + */ int size(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java index 828ff5dd3..152c14573 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IWorld.java @@ -28,6 +28,10 @@ public interface IWorld { */ IBlock getBlock(int x, int y, int z); + /** + * + * @return The top-most block in the world as an IBlock object. + */ IBlock getTopBlock(int x, int z); boolean isBlockFreezable(int x, int y, int z); @@ -42,10 +46,19 @@ public interface IWorld { boolean canSnowAtBody(int x, int y, int z, boolean checkLight); + /** + * @return The Y-value of the world at this x & z value based on the height map of the world. + */ int getHeightValue(int x, int z); + /** + * @return The minimum Y-value of the world at this x & z value based on the height map of the world. + */ int getChunkHeightMapMinimum(int x, int z); + /** + * @return The metadata of the block at this position. + */ int getBlockMetadata(int x, int y, int z); boolean setBlockMetadataWithNotify(int x, int y, int z, int metadata, int flag); @@ -72,12 +85,27 @@ public interface IWorld { IPlayer getClosestVulnerablePlayer(double x, double y, double z, double range); + /** + * + * @param entity The entity whose type will be used as a parameter + * @return The amount of entities of the given type in the world. + */ int countEntities(IEntity entity); + /** + * Sets the block's tile entity at the given position. + */ void setTileEntity(int x, int y, int z, ITileEntity tileEntity); + /** + * Removes the block's tile entity at the given position. + */ void removeTileEntity(int x, int y, int z); + /** + * + * @return True if the block at this position is of cubic shape. (Not a stair, slab, etc.) + */ boolean isBlockFullCube(int x, int y, int z); long getSeed(); @@ -173,6 +201,7 @@ public interface IWorld { * @param directory The particle's texture directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/tail.png" * @return Returns IEntityParticle object */ + @Deprecated IParticle createEntityParticle(String directory); /** @@ -266,6 +295,10 @@ public interface IWorld { ScriptScoreboard getScoreboard(); + /** + * + * @return An obfuscated MC BlockPos object. + */ BlockPos getMCBlockPos(int x, int y, int z); /** @@ -275,5 +308,9 @@ public interface IWorld { */ WorldServer getMCWorld(); + /** + * + * @return The ID of this world's dimension. 0 for overworld, 1 for End, -1 for Nether, etc. + */ int getDimensionID(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java index dec675a23..d45165fd1 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java @@ -169,7 +169,7 @@ public interface IPlayer extends IEntityLivingBase IEntity dropOneItem(boolean dropStack); - boolean canHarvestBlock(ScriptBlock block); + boolean canHarvestBlock(IBlock block); boolean interactWith(IEntity entity); From 7bd0155dbf89f0832889d2622353948f7c0db1eb Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Fri, 20 May 2022 05:02:18 -0500 Subject: [PATCH 59/75] Implemented player skin overlays to be compatible with other mods' custom player renderers (Renders on top using events instead of registering a new renderer). --- .../npcs/client/ClientEventHandler.java | 38 +- .../java/noppes/npcs/client/ClientProxy.java | 1 - .../client/renderer/RenderCNPCPlayer.java | 239 +++++-- .../RenderCNPCPlayerItemRenderer.java | 600 ++++++++++++++++++ 4 files changed, 835 insertions(+), 43 deletions(-) create mode 100644 src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayerItemRenderer.java diff --git a/src/main/java/noppes/npcs/client/ClientEventHandler.java b/src/main/java/noppes/npcs/client/ClientEventHandler.java index 90c49f506..9ff6e047a 100644 --- a/src/main/java/noppes/npcs/client/ClientEventHandler.java +++ b/src/main/java/noppes/npcs/client/ClientEventHandler.java @@ -1,12 +1,19 @@ package noppes.npcs.client; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import net.minecraft.client.renderer.OpenGlHelper; +import cpw.mods.fml.common.gameevent.TickEvent; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.entity.RenderManager; import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.client.event.RenderHandEvent; +import net.minecraftforge.client.event.RenderPlayerEvent; import noppes.npcs.client.gui.customoverlay.OverlayCustom; +import noppes.npcs.client.renderer.RenderCNPCPlayer; import org.lwjgl.opengl.GL11; public class ClientEventHandler { + RenderCNPCPlayer renderCNPCPlayer = new RenderCNPCPlayer(); + @SubscribeEvent public void onOverlayRender(RenderGameOverlayEvent.Post event){ if(event.type == RenderGameOverlayEvent.ElementType.ALL) { @@ -15,4 +22,33 @@ public class ClientEventHandler { } } } + + @SubscribeEvent + public void onRenderPlayer(RenderPlayerEvent.Post event) { + if (!(event.renderer instanceof RenderCNPCPlayer)) { + renderCNPCPlayer.doRender(event.entityPlayer, 0, 0, 0, 0.0F, event.partialRenderTick); + } + } + + @SubscribeEvent + public void onClientTick(TickEvent.ClientTickEvent event) { + Minecraft mc = Minecraft.getMinecraft(); + if (mc.thePlayer != null && mc.theWorld != null && !mc.isGamePaused() && event.phase == TickEvent.Phase.END) { + renderCNPCPlayer.itemRenderer.updateEquippedItem(); + renderCNPCPlayer.updateFovModifierHand(); + } + } + + @SubscribeEvent + public void onRenderHand(RenderHandEvent event) { + if (Client.skinOverlays.containsKey(Minecraft.getMinecraft().thePlayer.getUniqueID()) && Client.skinOverlays.get(Minecraft.getMinecraft().thePlayer.getUniqueID()).values().size() > 0) { + GL11.glPushMatrix(); + event.setCanceled(true); + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + renderCNPCPlayer.renderHand(event.partialTicks, event.renderPass); + GL11.glPopMatrix(); + } else { + event.setCanceled(false); + } + } } diff --git a/src/main/java/noppes/npcs/client/ClientProxy.java b/src/main/java/noppes/npcs/client/ClientProxy.java index caa5fc0a4..c663c371d 100644 --- a/src/main/java/noppes/npcs/client/ClientProxy.java +++ b/src/main/java/noppes/npcs/client/ClientProxy.java @@ -166,7 +166,6 @@ public class ClientProxy extends CommonProxy { RenderingRegistry.registerEntityRenderingHandler(EntityProjectile.class, new RenderProjectile()); RenderingRegistry.registerEntityRenderingHandler(EntityCustomNpc.class, new RenderCustomNpc()); - RenderingRegistry.registerEntityRenderingHandler(EntityPlayer.class, new RenderCNPCPlayer()); RenderingRegistry.registerEntityRenderingHandler(EntityNPCGolem.class, new RenderNPCHumanMale( new ModelNPCGolem(0), new ModelNPCGolem(1F), new ModelNPCGolem(0.5F))); diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index 69a6e3440..9ed1d62d0 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -1,19 +1,43 @@ package noppes.npcs.client.renderer; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.renderer.ActiveRenderInfo; +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import noppes.npcs.client.Client; import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.controllers.data.SkinOverlayData; import org.lwjgl.opengl.GL11; +import org.lwjgl.util.glu.Project; public class RenderCNPCPlayer extends RenderPlayer { + public RenderCNPCPlayerItemRenderer itemRenderer = new RenderCNPCPlayerItemRenderer(Minecraft.getMinecraft()); + private float debugCamFOV; + private float prevDebugCamFOV; + private float fovModifierHand; + private float fovModifierHandPrev; + private float fovMultiplierTemp; + public RenderCNPCPlayer() { + super(); + this.modelBipedMain = (ModelBiped)this.mainModel; + this.modelArmorChestplate = new ModelBiped(1.0F); + this.modelArmor = new ModelBiped(0.5F); + this.setRenderManager(RenderManager.instance); } - private boolean preRenderOverlay(boolean firstPerson, EntityPlayer player, ResourceLocation overlayLocation, boolean glow, + private boolean preRenderOverlay(float partialTickTime, EntityPlayer player, ResourceLocation overlayLocation, boolean glow, float alpha, float size, float speedX, float speedY, float scaleX, float scaleY, float offsetX, float offsetY, float offsetZ) { try { @@ -22,23 +46,14 @@ public class RenderCNPCPlayer extends RenderPlayer { return false; } - float renderTicks; - if (firstPerson) { - if (!Client.fpSkinOverlayTicks.containsKey(player.getUniqueID())) { - Client.fpSkinOverlayTicks.put(player.getUniqueID(), 1L); - } else { - long ticks = Client.fpSkinOverlayTicks.get(player.getUniqueID()); - Client.fpSkinOverlayTicks.put(player.getUniqueID(), ticks + 1); - } - renderTicks = Client.fpSkinOverlayTicks.get(player.getUniqueID()); - } else { + if (partialTickTime == 0) { if (!Client.entitySkinOverlayTicks.containsKey(player.getUniqueID())) { Client.entitySkinOverlayTicks.put(player.getUniqueID(), 1L); } else { long ticks = Client.entitySkinOverlayTicks.get(player.getUniqueID()); Client.entitySkinOverlayTicks.put(player.getUniqueID(), ticks + 1); } - renderTicks = Client.entitySkinOverlayTicks.get(player.getUniqueID());; + partialTickTime = Client.entitySkinOverlayTicks.get(player.getUniqueID());; } // Overlay & Glow @@ -48,6 +63,7 @@ public class RenderCNPCPlayer extends RenderPlayer { GL11.glDisable(GL11.GL_LIGHTING); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); Minecraft.getMinecraft().entityRenderer.disableLightmap((double)0); + RenderHelper.disableStandardItemLighting(); } GL11.glColor4f(1.0F, 1.0F, 1.0F, alpha); @@ -57,13 +73,12 @@ public class RenderCNPCPlayer extends RenderPlayer { GL11.glPushMatrix(); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glLoadIdentity(); - GL11.glTranslatef(renderTicks * 0.001F * speedX, renderTicks * 0.001F * speedY, 0.0F); + GL11.glTranslatef(partialTickTime * 0.001F * speedX, partialTickTime * 0.001F * speedY, 0.0F); GL11.glScalef(scaleX, scaleY, 1.0F); GL11.glMatrixMode(GL11.GL_MODELVIEW); - float scale = 1.005f * size; GL11.glTranslatef(offsetX, offsetY, offsetZ); - GL11.glScalef(scale, scale, scale); + GL11.glScalef(size, size, size); return true; } @@ -79,17 +94,15 @@ public class RenderCNPCPlayer extends RenderPlayer { GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDisable(GL11.GL_BLEND); Minecraft.getMinecraft().entityRenderer.enableLightmap((double)0); + RenderHelper.enableStandardItemLighting(); } @Override protected void renderModel(EntityLivingBase p_77036_1_, float p_77036_2_, float p_77036_3_, float p_77036_4_, float p_77036_5_, float p_77036_6_, float p_77036_7_) { EntityPlayer player = (EntityPlayer) p_77036_1_; - this.bindEntityTexture(p_77036_1_); if (!p_77036_1_.isInvisible()) { - this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); - if (Client.skinOverlays.containsKey(player.getUniqueID())) { for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { if (overlayData.location == null) { @@ -101,45 +114,189 @@ public class RenderCNPCPlayer extends RenderPlayer { } } - if (!preRenderOverlay(false, player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size, + if (!preRenderOverlay(0, player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size, overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY, overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ )) return; - this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); + this.modelBipedMain.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); postRenderOverlay(player); } } else if(player.getEntityData().hasKey("SkinOverlayData")) { Client.sendData(EnumPacketServer.SERVER_UPDATE_SKIN_OVERLAYS, new Object[0]); } } - else if (!p_77036_1_.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) + } + + public void renderHand(float partialTicks, int renderPass) { + Minecraft mc = Minecraft.getMinecraft(); + EntityRenderer entityRenderer = mc.entityRenderer; + EntityClientPlayerMP player = mc.thePlayer; + + if (entityRenderer.debugViewDirection <= 0) { + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + float f1 = 0.07F; + + if (mc.gameSettings.anaglyph) + { + GL11.glTranslatef((float)(-(renderPass * 2 - 1)) * f1, 0.0F, 0.0F); + } + + /*if (entityRenderer.cameraZoom != 1.0D) //EntityRenderer's "cameraZoom" field is always 1.0D??? Why is this here??? o_O + { + GL11.glTranslatef((float)player.cameraYaw, (float)(-player.cameraPitch), 0.0F); + GL11.glScaled(entityRenderer.cameraZoom, entityRenderer.cameraZoom, 1.0D); + }*/ + + Project.gluPerspective(this.getFOVModifier(partialTicks, false), (float)mc.displayWidth / (float)mc.displayHeight, 0.05F, mc.gameSettings.renderDistanceChunks * 16 * 2.0F); + + if (mc.playerController.enableEverythingIsScrewedUpMode()) + { + float f2 = 0.6666667F; + GL11.glScalef(1.0F, f2, 1.0F); + } + + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + + if (mc.gameSettings.anaglyph) + { + GL11.glTranslatef((float)(renderPass * 2 - 1) * 0.1F, 0.0F, 0.0F); + } + GL11.glPushMatrix(); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.15F); - GL11.glDepthMask(false); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); - this.mainModel.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); - GL11.glDisable(GL11.GL_BLEND); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + hurtCameraEffect(partialTicks); + + if (mc.gameSettings.viewBobbing) + { + setupViewBobbing(partialTicks); + } + + if (mc.gameSettings.thirdPersonView == 0 && !mc.renderViewEntity.isPlayerSleeping() && !mc.gameSettings.hideGUI && !mc.playerController.enableEverythingIsScrewedUpMode()) + { + itemRenderer.updateEquippedItem(); + entityRenderer.enableLightmap((double)partialTicks); + itemRenderer.renderItemInFirstPerson(partialTicks); + entityRenderer.disableLightmap((double)partialTicks); + } + GL11.glPopMatrix(); - GL11.glDepthMask(true); - } - else - { - this.mainModel.setRotationAngles(p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_, p_77036_1_); + + if (mc.gameSettings.thirdPersonView == 0 && !mc.renderViewEntity.isPlayerSleeping()) + { + entityRenderer.itemRenderer.renderOverlays(partialTicks); + hurtCameraEffect(partialTicks); + } + + if (mc.gameSettings.viewBobbing) + { + setupViewBobbing(partialTicks); + } } } - public void renderFirstPersonArm(EntityPlayer player) + private float getFOVModifier(float p_78481_1_, boolean p_78481_2_) { - float f = 1.0F; - GL11.glColor3f(f, f, f); - this.modelBipedMain.onGround = 0.0F; - this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, player); - this.modelBipedMain.bipedRightArm.render(0.0625F); + Minecraft mc = Minecraft.getMinecraft(); + EntityLivingBase entityplayer = (EntityLivingBase)mc.renderViewEntity; + float f1 = 70.0F; + + if (p_78481_2_) + { + f1 = mc.gameSettings.fovSetting; + f1 *= this.fovModifierHandPrev + (this.fovModifierHand - this.fovModifierHandPrev) * p_78481_1_; + } + + if (entityplayer.getHealth() <= 0.0F) + { + float f2 = (float)entityplayer.deathTime + p_78481_1_; + f1 /= (1.0F - 500.0F / (f2 + 500.0F)) * 2.0F + 1.0F; + } + + Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(mc.theWorld, entityplayer, p_78481_1_); + + if (block.getMaterial() == Material.water) + { + f1 = f1 * 60.0F / 70.0F; + } + + return f1 + this.prevDebugCamFOV + (this.debugCamFOV - this.prevDebugCamFOV) * p_78481_1_; + } + + public void updateFovModifierHand() + { + Minecraft mc = Minecraft.getMinecraft(); + if (mc.renderViewEntity instanceof EntityPlayerSP) + { + EntityPlayerSP entityplayersp = (EntityPlayerSP)mc.renderViewEntity; + this.fovMultiplierTemp = entityplayersp.getFOVMultiplier(); + } + else + { + this.fovMultiplierTemp = mc.thePlayer.getFOVMultiplier(); + } + this.fovModifierHandPrev = this.fovModifierHand; + this.fovModifierHand += (this.fovMultiplierTemp - this.fovModifierHand) * 0.5F; + + if (this.fovModifierHand > 1.5F) + { + this.fovModifierHand = 1.5F; + } + + if (this.fovModifierHand < 0.1F) + { + this.fovModifierHand = 0.1F; + } + } + + private void hurtCameraEffect(float p_78482_1_) + { + Minecraft mc = Minecraft.getMinecraft(); + EntityLivingBase entitylivingbase = mc.renderViewEntity; + float f1 = (float)entitylivingbase.hurtTime - p_78482_1_; + float f2; + + if (entitylivingbase.getHealth() <= 0.0F) + { + f2 = (float)entitylivingbase.deathTime + p_78482_1_; + GL11.glRotatef(40.0F - 8000.0F / (f2 + 200.0F), 0.0F, 0.0F, 1.0F); + } + + if (f1 >= 0.0F) + { + f1 /= (float)entitylivingbase.maxHurtTime; + f1 = MathHelper.sin(f1 * f1 * f1 * f1 * (float)Math.PI); + f2 = entitylivingbase.attackedAtYaw; + GL11.glRotatef(-f2, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-f1 * 14.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(f2, 0.0F, 1.0F, 0.0F); + } + } + + private void setupViewBobbing(float p_78475_1_) + { + Minecraft mc = Minecraft.getMinecraft(); + if (mc.renderViewEntity instanceof EntityPlayer) + { + EntityPlayer entityplayer = (EntityPlayer)mc.renderViewEntity; + float f1 = entityplayer.distanceWalkedModified - entityplayer.prevDistanceWalkedModified; + float f2 = -(entityplayer.distanceWalkedModified + f1 * p_78475_1_); + float f3 = entityplayer.prevCameraYaw + (entityplayer.cameraYaw - entityplayer.prevCameraYaw) * p_78475_1_; + float f4 = entityplayer.prevCameraPitch + (entityplayer.cameraPitch - entityplayer.prevCameraPitch) * p_78475_1_; + GL11.glTranslatef(MathHelper.sin(f2 * (float)Math.PI) * f3 * 0.5F, -Math.abs(MathHelper.cos(f2 * (float)Math.PI) * f3), 0.0F); + GL11.glRotatef(MathHelper.sin(f2 * (float)Math.PI) * f3 * 3.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(Math.abs(MathHelper.cos(f2 * (float)Math.PI - 0.2F) * f3) * 5.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(f4, 1.0F, 0.0F, 0.0F); + } + } + + public void renderFirstPersonArm(EntityPlayer player, float partialTickTime) + { + Render render = RenderManager.instance.getEntityRenderObject(player); + RenderPlayer renderplayer = (RenderPlayer)render; + renderplayer.renderFirstPersonArm(player); if (Client.skinOverlays.containsKey(player.getUniqueID())) { for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { @@ -152,7 +309,7 @@ public class RenderCNPCPlayer extends RenderPlayer { } } - if (!preRenderOverlay(false, player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size, + if (!preRenderOverlay(partialTickTime, player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size, overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY, overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ )) diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayerItemRenderer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayerItemRenderer.java new file mode 100644 index 000000000..d799b8ede --- /dev/null +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayerItemRenderer.java @@ -0,0 +1,600 @@ +package noppes.npcs.client.renderer; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.*; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.storage.MapData; +import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; +import noppes.npcs.controllers.data.SkinOverlayData; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import static net.minecraftforge.client.IItemRenderer.ItemRenderType.*; + +public class RenderCNPCPlayerItemRenderer extends ItemRenderer { + private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + private static final ResourceLocation RES_MAP_BACKGROUND = new ResourceLocation("textures/map/map_background.png"); + private static final ResourceLocation RES_UNDERWATER_OVERLAY = new ResourceLocation("textures/misc/underwater.png"); + + /** A reference to the Minecraft object. */ + private Minecraft mc; + private ItemStack itemToRender; + /** How far the current item has been equipped (0 disequipped and 1 fully up) */ + private float equippedProgress; + private float prevEquippedProgress; + private RenderBlocks renderBlocksIr = new RenderBlocks(); + /** The index of the currently held item (0-8, or -1 if not yet updated) */ + private int equippedItemSlot = -1; + + public RenderCNPCPlayerItemRenderer(Minecraft mc) { + super(mc); + this.mc = mc; + } + + public void renderItem(EntityLivingBase p_78443_1_, ItemStack p_78443_2_, int p_78443_3_) + { + this.renderItem(p_78443_1_, p_78443_2_, p_78443_3_, EQUIPPED); + } + + public void renderItem(EntityLivingBase p_78443_1_, ItemStack p_78443_2_, int p_78443_3_, IItemRenderer.ItemRenderType type) + { + GL11.glPushMatrix(); + TextureManager texturemanager = this.mc.getTextureManager(); + Item item = p_78443_2_.getItem(); + Block block = Block.getBlockFromItem(item); + + if (p_78443_2_ != null && block != null && block.getRenderBlockPass() != 0) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_CULL_FACE); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + } + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(p_78443_2_, type); + if (customRenderer != null) + { + texturemanager.bindTexture(texturemanager.getResourceLocation(p_78443_2_.getItemSpriteNumber())); + ForgeHooksClient.renderEquippedItem(type, customRenderer, renderBlocksIr, p_78443_1_, p_78443_2_); + } + else + if (p_78443_2_.getItemSpriteNumber() == 0 && item instanceof ItemBlock && RenderBlocks.renderItemIn3d(block.getRenderType())) + { + texturemanager.bindTexture(texturemanager.getResourceLocation(0)); + + if (p_78443_2_ != null && block != null && block.getRenderBlockPass() != 0) + { + GL11.glDepthMask(false); + this.renderBlocksIr.renderBlockAsItem(block, p_78443_2_.getItemDamage(), 1.0F); + GL11.glDepthMask(true); + } + else + { + this.renderBlocksIr.renderBlockAsItem(block, p_78443_2_.getItemDamage(), 1.0F); + } + } + else + { + IIcon iicon = p_78443_1_.getItemIcon(p_78443_2_, p_78443_3_); + + if (iicon == null) + { + GL11.glPopMatrix(); + return; + } + + texturemanager.bindTexture(texturemanager.getResourceLocation(p_78443_2_.getItemSpriteNumber())); + TextureUtil.func_152777_a(false, false, 1.0F); + Tessellator tessellator = Tessellator.instance; + float f = iicon.getMinU(); + float f1 = iicon.getMaxU(); + float f2 = iicon.getMinV(); + float f3 = iicon.getMaxV(); + float f4 = 0.0F; + float f5 = 0.3F; + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glTranslatef(-f4, -f5, 0.0F); + float f6 = 1.5F; + GL11.glScalef(f6, f6, f6); + GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F); + renderItemIn2D(tessellator, f1, f2, f, f3, iicon.getIconWidth(), iicon.getIconHeight(), 0.0625F); + + if (p_78443_2_.hasEffect(p_78443_3_)) + { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + texturemanager.bindTexture(RES_ITEM_GLINT); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(768, 1, 1, 0); + float f7 = 0.76F; + GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + float f8 = 0.125F; + GL11.glScalef(f8, f8, f8); + float f9 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + GL11.glTranslatef(f9, 0.0F, 0.0F); + GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); + renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f8, f8, f8); + f9 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + GL11.glTranslatef(-f9, 0.0F, 0.0F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); + renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + texturemanager.bindTexture(texturemanager.getResourceLocation(p_78443_2_.getItemSpriteNumber())); + TextureUtil.func_147945_b(); + } + + if (p_78443_2_ != null && block != null && block.getRenderBlockPass() != 0) + { + GL11.glDisable(GL11.GL_BLEND); + } + + GL11.glPopMatrix(); + } + + /** + * Renders an item held in hand as a 2D texture with thickness + */ + public static void renderItemIn2D(Tessellator p_78439_0_, float p_78439_1_, float p_78439_2_, float p_78439_3_, float p_78439_4_, int p_78439_5_, int p_78439_6_, float p_78439_7_) + { + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(0.0F, 0.0F, 1.0F); + p_78439_0_.addVertexWithUV(0.0D, 0.0D, 0.0D, (double)p_78439_1_, (double)p_78439_4_); + p_78439_0_.addVertexWithUV(1.0D, 0.0D, 0.0D, (double)p_78439_3_, (double)p_78439_4_); + p_78439_0_.addVertexWithUV(1.0D, 1.0D, 0.0D, (double)p_78439_3_, (double)p_78439_2_); + p_78439_0_.addVertexWithUV(0.0D, 1.0D, 0.0D, (double)p_78439_1_, (double)p_78439_2_); + p_78439_0_.draw(); + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(0.0F, 0.0F, -1.0F); + p_78439_0_.addVertexWithUV(0.0D, 1.0D, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)p_78439_2_); + p_78439_0_.addVertexWithUV(1.0D, 1.0D, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)p_78439_2_); + p_78439_0_.addVertexWithUV(1.0D, 0.0D, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)p_78439_4_); + p_78439_0_.addVertexWithUV(0.0D, 0.0D, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)p_78439_4_); + p_78439_0_.draw(); + float f5 = 0.5F * (p_78439_1_ - p_78439_3_) / (float)p_78439_5_; + float f6 = 0.5F * (p_78439_4_ - p_78439_2_) / (float)p_78439_6_; + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(-1.0F, 0.0F, 0.0F); + int k; + float f7; + float f8; + + for (k = 0; k < p_78439_5_; ++k) + { + f7 = (float)k / (float)p_78439_5_; + f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5; + p_78439_0_.addVertexWithUV((double)f7, 0.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_4_); + p_78439_0_.addVertexWithUV((double)f7, 0.0D, 0.0D, (double)f8, (double)p_78439_4_); + p_78439_0_.addVertexWithUV((double)f7, 1.0D, 0.0D, (double)f8, (double)p_78439_2_); + p_78439_0_.addVertexWithUV((double)f7, 1.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_2_); + } + + p_78439_0_.draw(); + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(1.0F, 0.0F, 0.0F); + float f9; + + for (k = 0; k < p_78439_5_; ++k) + { + f7 = (float)k / (float)p_78439_5_; + f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5; + f9 = f7 + 1.0F / (float)p_78439_5_; + p_78439_0_.addVertexWithUV((double)f9, 1.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_2_); + p_78439_0_.addVertexWithUV((double)f9, 1.0D, 0.0D, (double)f8, (double)p_78439_2_); + p_78439_0_.addVertexWithUV((double)f9, 0.0D, 0.0D, (double)f8, (double)p_78439_4_); + p_78439_0_.addVertexWithUV((double)f9, 0.0D, (double)(0.0F - p_78439_7_), (double)f8, (double)p_78439_4_); + } + + p_78439_0_.draw(); + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(0.0F, 1.0F, 0.0F); + + for (k = 0; k < p_78439_6_; ++k) + { + f7 = (float)k / (float)p_78439_6_; + f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6; + f9 = f7 + 1.0F / (float)p_78439_6_; + p_78439_0_.addVertexWithUV(0.0D, (double)f9, 0.0D, (double)p_78439_1_, (double)f8); + p_78439_0_.addVertexWithUV(1.0D, (double)f9, 0.0D, (double)p_78439_3_, (double)f8); + p_78439_0_.addVertexWithUV(1.0D, (double)f9, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)f8); + p_78439_0_.addVertexWithUV(0.0D, (double)f9, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)f8); + } + + p_78439_0_.draw(); + p_78439_0_.startDrawingQuads(); + p_78439_0_.setNormal(0.0F, -1.0F, 0.0F); + + for (k = 0; k < p_78439_6_; ++k) + { + f7 = (float)k / (float)p_78439_6_; + f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6; + p_78439_0_.addVertexWithUV(1.0D, (double)f7, 0.0D, (double)p_78439_3_, (double)f8); + p_78439_0_.addVertexWithUV(0.0D, (double)f7, 0.0D, (double)p_78439_1_, (double)f8); + p_78439_0_.addVertexWithUV(0.0D, (double)f7, (double)(0.0F - p_78439_7_), (double)p_78439_1_, (double)f8); + p_78439_0_.addVertexWithUV(1.0D, (double)f7, (double)(0.0F - p_78439_7_), (double)p_78439_3_, (double)f8); + } + + p_78439_0_.draw(); + } + + /** + * Renders the active item in the player's hand when in first person mode. Args: partialTickTime + */ + public void renderItemInFirstPerson(float partialTickTime) + { + float f1 = this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * partialTickTime; + EntityClientPlayerMP entityclientplayermp = this.mc.thePlayer; + float f2 = entityclientplayermp.prevRotationPitch + (entityclientplayermp.rotationPitch - entityclientplayermp.prevRotationPitch) * partialTickTime; + GL11.glPushMatrix(); + GL11.glRotatef(f2, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(entityclientplayermp.prevRotationYaw + (entityclientplayermp.rotationYaw - entityclientplayermp.prevRotationYaw) * partialTickTime, 0.0F, 1.0F, 0.0F); + RenderHelper.enableStandardItemLighting(); + GL11.glPopMatrix(); + EntityPlayerSP entityplayersp = (EntityPlayerSP)entityclientplayermp; + float f3 = entityplayersp.prevRenderArmPitch + (entityplayersp.renderArmPitch - entityplayersp.prevRenderArmPitch) * partialTickTime; + float f4 = entityplayersp.prevRenderArmYaw + (entityplayersp.renderArmYaw - entityplayersp.prevRenderArmYaw) * partialTickTime; + GL11.glRotatef((entityclientplayermp.rotationPitch - f3) * 0.1F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef((entityclientplayermp.rotationYaw - f4) * 0.1F, 0.0F, 1.0F, 0.0F); + + + ItemStack itemstack = this.itemToRender; + RenderCNPCPlayer renderCNPCPlayer = new RenderCNPCPlayer(); + + if (itemstack != null && itemstack.getItem() instanceof ItemCloth) + { + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + } + + int i = this.mc.theWorld.getLightBrightnessForSkyBlocks(MathHelper.floor_double(entityclientplayermp.posX), MathHelper.floor_double(entityclientplayermp.posY), MathHelper.floor_double(entityclientplayermp.posZ), 0); + int j = i % 65536; + int k = i / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + float f5; + float f6; + float f7; + + if (itemstack != null) + { + int l = itemstack.getItem().getColorFromItemStack(itemstack, 0); + f5 = (float)(l >> 16 & 255) / 255.0F; + f6 = (float)(l >> 8 & 255) / 255.0F; + f7 = (float)(l & 255) / 255.0F; + GL11.glColor4f(f5, f6, f7, 1.0F); + } + else + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + float f8; + float f9; + float f10; + float f13; + Render render; + RenderPlayer renderplayer; + + if (itemstack != null && itemstack.getItem() instanceof ItemMap) + { + GL11.glPushMatrix(); + f13 = 0.8F; + f5 = entityclientplayermp.getSwingProgress(partialTickTime); + f6 = MathHelper.sin(f5 * (float)Math.PI); + f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI); + GL11.glTranslatef(-f7 * 0.4F, MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI * 2.0F) * 0.2F, -f6 * 0.2F); + f5 = 1.0F - f2 / 45.0F + 0.1F; + + if (f5 < 0.0F) + { + f5 = 0.0F; + } + + if (f5 > 1.0F) + { + f5 = 1.0F; + } + + f5 = -MathHelper.cos(f5 * (float)Math.PI) * 0.5F + 0.5F; + GL11.glTranslatef(0.0F, 0.0F * f13 - (1.0F - f1) * 1.2F - f5 * 0.5F + 0.04F, -0.9F * f13); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(f5 * -85.0F, 0.0F, 0.0F, 1.0F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + this.mc.getTextureManager().bindTexture(entityclientplayermp.getLocationSkin()); + + for (int i1 = 0; i1 < 2; ++i1) + { + int j1 = i1 * 2 - 1; + GL11.glPushMatrix(); + GL11.glTranslatef(-0.0F, -0.6F, 1.1F * (float)j1); + GL11.glRotatef((float)(-45 * j1), 1.0F, 0.0F, 0.0F); + GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(59.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef((float)(-65 * j1), 0.0F, 1.0F, 0.0F); + render = RenderManager.instance.getEntityRenderObject(this.mc.thePlayer); + renderplayer = (RenderPlayer)render; + f10 = 1.0F; + GL11.glScalef(f10, f10, f10); + renderCNPCPlayer.renderFirstPersonArm(this.mc.thePlayer,partialTickTime); + GL11.glPopMatrix(); + } + + f6 = entityclientplayermp.getSwingProgress(partialTickTime); + f7 = MathHelper.sin(f6 * f6 * (float)Math.PI); + f8 = MathHelper.sin(MathHelper.sqrt_float(f6) * (float)Math.PI); + GL11.glRotatef(-f7 * 20.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-f8 * 20.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-f8 * 80.0F, 1.0F, 0.0F, 0.0F); + f9 = 0.38F; + GL11.glScalef(f9, f9, f9); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-1.0F, -1.0F, 0.0F); + f10 = 0.015625F; + GL11.glScalef(f10, f10, f10); + this.mc.getTextureManager().bindTexture(RES_MAP_BACKGROUND); + Tessellator tessellator = Tessellator.instance; + GL11.glNormal3f(0.0F, 0.0F, -1.0F); + tessellator.startDrawingQuads(); + byte b0 = 7; + tessellator.addVertexWithUV((double)(0 - b0), (double)(128 + b0), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)(128 + b0), (double)(128 + b0), 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)(128 + b0), (double)(0 - b0), 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)(0 - b0), (double)(0 - b0), 0.0D, 0.0D, 0.0D); + tessellator.draw(); + + IItemRenderer custom = MinecraftForgeClient.getItemRenderer(itemstack, FIRST_PERSON_MAP); + MapData mapdata = ((ItemMap)itemstack.getItem()).getMapData(itemstack, this.mc.theWorld); + + if (custom == null) + { + if (mapdata != null) + { + this.mc.entityRenderer.getMapItemRenderer().func_148250_a(mapdata, false); + } + } + else + { + custom.renderItem(FIRST_PERSON_MAP, itemstack, mc.thePlayer, mc.getTextureManager(), mapdata); + } + + GL11.glPopMatrix(); + } + else if (itemstack != null) + { + GL11.glPushMatrix(); + f13 = 0.8F; + + if (entityclientplayermp.getItemInUseCount() > 0) + { + EnumAction enumaction = itemstack.getItemUseAction(); + + if (enumaction == EnumAction.eat || enumaction == EnumAction.drink) + { + f6 = (float)entityclientplayermp.getItemInUseCount() - partialTickTime + 1.0F; + f7 = 1.0F - f6 / (float)itemstack.getMaxItemUseDuration(); + f8 = 1.0F - f7; + f8 = f8 * f8 * f8; + f8 = f8 * f8 * f8; + f8 = f8 * f8 * f8; + f9 = 1.0F - f8; + GL11.glTranslatef(0.0F, MathHelper.abs(MathHelper.cos(f6 / 4.0F * (float)Math.PI) * 0.1F) * (float)((double)f7 > 0.2D ? 1 : 0), 0.0F); + GL11.glTranslatef(f9 * 0.6F, -f9 * 0.5F, 0.0F); + GL11.glRotatef(f9 * 90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(f9 * 10.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(f9 * 30.0F, 0.0F, 0.0F, 1.0F); + } + } + else + { + f5 = entityclientplayermp.getSwingProgress(partialTickTime); + f6 = MathHelper.sin(f5 * (float)Math.PI); + f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI); + GL11.glTranslatef(-f7 * 0.4F, MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI * 2.0F) * 0.2F, -f6 * 0.2F); + } + + GL11.glTranslatef(0.7F * f13, -0.65F * f13 - (1.0F - f1) * 0.6F, -0.9F * f13); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + f5 = entityclientplayermp.getSwingProgress(partialTickTime); + f6 = MathHelper.sin(f5 * f5 * (float)Math.PI); + f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI); + GL11.glRotatef(-f6 * 20.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-f7 * 20.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-f7 * 80.0F, 1.0F, 0.0F, 0.0F); + f8 = 0.4F; + GL11.glScalef(f8, f8, f8); + float f11; + float f12; + + if (entityclientplayermp.getItemInUseCount() > 0) + { + EnumAction enumaction1 = itemstack.getItemUseAction(); + + if (enumaction1 == EnumAction.block) + { + GL11.glTranslatef(-0.5F, 0.2F, 0.0F); + GL11.glRotatef(30.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-80.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(60.0F, 0.0F, 1.0F, 0.0F); + } + else if (enumaction1 == EnumAction.bow) + { + GL11.glRotatef(-18.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-12.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-8.0F, 1.0F, 0.0F, 0.0F); + GL11.glTranslatef(-0.9F, 0.2F, 0.0F); + f10 = (float)itemstack.getMaxItemUseDuration() - ((float)entityclientplayermp.getItemInUseCount() - partialTickTime + 1.0F); + f11 = f10 / 20.0F; + f11 = (f11 * f11 + f11 * 2.0F) / 3.0F; + + if (f11 > 1.0F) + { + f11 = 1.0F; + } + + if (f11 > 0.1F) + { + GL11.glTranslatef(0.0F, MathHelper.sin((f10 - 0.1F) * 1.3F) * 0.01F * (f11 - 0.1F), 0.0F); + } + + GL11.glTranslatef(0.0F, 0.0F, f11 * 0.1F); + GL11.glRotatef(-335.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.5F, 0.0F); + f12 = 1.0F + f11 * 0.2F; + GL11.glScalef(1.0F, 1.0F, f12); + GL11.glTranslatef(0.0F, -0.5F, 0.0F); + GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); + } + } + + if (itemstack.getItem().shouldRotateAroundWhenRendering()) + { + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + } + + if (itemstack.getItem().requiresMultipleRenderPasses()) + { + this.renderItem(entityclientplayermp, itemstack, 0, EQUIPPED_FIRST_PERSON); + for (int x = 1; x < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); x++) + { + int k1 = itemstack.getItem().getColorFromItemStack(itemstack, x); + f10 = (float)(k1 >> 16 & 255) / 255.0F; + f11 = (float)(k1 >> 8 & 255) / 255.0F; + f12 = (float)(k1 & 255) / 255.0F; + GL11.glColor4f(1.0F * f10, 1.0F * f11, 1.0F * f12, 1.0F); + this.renderItem(entityclientplayermp, itemstack, x, EQUIPPED_FIRST_PERSON); + } + } + else + { + this.renderItem(entityclientplayermp, itemstack, 0, EQUIPPED_FIRST_PERSON); + } + + GL11.glPopMatrix(); + } + else if (!entityclientplayermp.isInvisible()) + { + GL11.glPushMatrix(); + f13 = 0.8F; + f5 = entityclientplayermp.getSwingProgress(partialTickTime); + f6 = MathHelper.sin(f5 * (float)Math.PI); + f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI); + GL11.glTranslatef(-f7 * 0.3F, MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI * 2.0F) * 0.4F, -f6 * 0.4F); + GL11.glTranslatef(0.8F * f13, -0.75F * f13 - (1.0F - f1) * 0.6F, -0.9F * f13); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + f5 = entityclientplayermp.getSwingProgress(partialTickTime); + f6 = MathHelper.sin(f5 * f5 * (float)Math.PI); + f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI); + GL11.glRotatef(f7 * 70.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-f6 * 20.0F, 0.0F, 0.0F, 1.0F); + this.mc.getTextureManager().bindTexture(entityclientplayermp.getLocationSkin()); + GL11.glTranslatef(-1.0F, 3.6F, 3.5F); + GL11.glRotatef(120.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(200.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(1.0F, 1.0F, 1.0F); + GL11.glTranslatef(5.6F, 0.0F, 0.0F); + + render = RenderManager.instance.getEntityRenderObject(this.mc.thePlayer); + renderplayer = (RenderPlayer)render; + f10 = 1.0F; + GL11.glScalef(f10, f10, f10); + renderCNPCPlayer.renderFirstPersonArm(this.mc.thePlayer,partialTickTime); + GL11.glPopMatrix(); + } + + if (itemstack != null && itemstack.getItem() instanceof ItemCloth) + { + GL11.glDisable(GL11.GL_BLEND); + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + } + + public void updateEquippedItem() + { + this.prevEquippedProgress = this.equippedProgress; + EntityClientPlayerMP entityclientplayermp = this.mc.thePlayer; + ItemStack itemstack = entityclientplayermp.inventory.getCurrentItem(); + boolean flag = this.equippedItemSlot == entityclientplayermp.inventory.currentItem && itemstack == this.itemToRender; + + if (this.itemToRender == null && itemstack == null) + { + flag = true; + } + + if (itemstack != null && this.itemToRender != null && itemstack != this.itemToRender && itemstack.getItem() == this.itemToRender.getItem() && itemstack.getItemDamage() == this.itemToRender.getItemDamage()) + { + this.itemToRender = itemstack; + flag = true; + } + + float f = 0.4F; + float f1 = flag ? 1.0F : 0.0F; + float f2 = f1 - this.equippedProgress; + + if (f2 < -f) + { + f2 = -f; + } + + if (f2 > f) + { + f2 = f; + } + + this.equippedProgress += f2/4.0F; + + if (this.equippedProgress < 0.1F) + { + this.itemToRender = itemstack; + this.equippedItemSlot = entityclientplayermp.inventory.currentItem; + } + } + + /** + * Resets equippedProgress + */ + public void resetEquippedProgress() + { + this.equippedProgress = 0.0F; + } + + /** + * Resets equippedProgress + */ + public void resetEquippedProgress2() + { + this.equippedProgress = 0.0F; + } +} From 0a067eceb59ed6f4fd898aea4d3763b4665270de Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Sat, 21 May 2022 20:00:45 -0500 Subject: [PATCH 60/75] Added DBC support for overlays. --- src/main/java/noppes/npcs/client/Client.java | 2 +- .../npcs/client/ClientEventHandler.java | 8 +- ...Renderer.java => OverlayRenderHelper.java} | 5 +- .../client/renderer/RenderCNPCPlayer.java | 703 +++++++++++++++++- 4 files changed, 709 insertions(+), 9 deletions(-) rename src/main/java/noppes/npcs/client/renderer/{RenderCNPCPlayerItemRenderer.java => OverlayRenderHelper.java} (99%) diff --git a/src/main/java/noppes/npcs/client/Client.java b/src/main/java/noppes/npcs/client/Client.java index 48451bb6c..b09ea4fb2 100644 --- a/src/main/java/noppes/npcs/client/Client.java +++ b/src/main/java/noppes/npcs/client/Client.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.util.HashMap; import java.util.UUID; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import noppes.npcs.CustomNpcs; import noppes.npcs.Server; @@ -19,7 +20,6 @@ public class Client { public static HashMap customOverlays = new HashMap<>(); public static HashMap> skinOverlays = new HashMap<>(); - public static HashMap fpSkinOverlayTicks = new HashMap<>(); public static HashMap entitySkinOverlayTicks = new HashMap<>(); public static void sendData(EnumPacketServer enu, Object... obs) { diff --git a/src/main/java/noppes/npcs/client/ClientEventHandler.java b/src/main/java/noppes/npcs/client/ClientEventHandler.java index 9ff6e047a..a1e28d3bc 100644 --- a/src/main/java/noppes/npcs/client/ClientEventHandler.java +++ b/src/main/java/noppes/npcs/client/ClientEventHandler.java @@ -3,7 +3,6 @@ package noppes.npcs.client; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.RenderManager; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderHandEvent; import net.minecraftforge.client.event.RenderPlayerEvent; @@ -26,10 +25,17 @@ public class ClientEventHandler { @SubscribeEvent public void onRenderPlayer(RenderPlayerEvent.Post event) { if (!(event.renderer instanceof RenderCNPCPlayer)) { + renderCNPCPlayer.tempRenderPartialTicks = event.partialRenderTick; renderCNPCPlayer.doRender(event.entityPlayer, 0, 0, 0, 0.0F, event.partialRenderTick); } } + @SubscribeEvent + public void cancelSpecials(RenderPlayerEvent.Specials.Pre event) { + if (event.renderer instanceof RenderCNPCPlayer) + event.setCanceled(true); + } + @SubscribeEvent public void onClientTick(TickEvent.ClientTickEvent event) { Minecraft mc = Minecraft.getMinecraft(); diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayerItemRenderer.java b/src/main/java/noppes/npcs/client/renderer/OverlayRenderHelper.java similarity index 99% rename from src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayerItemRenderer.java rename to src/main/java/noppes/npcs/client/renderer/OverlayRenderHelper.java index d799b8ede..f8394b610 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayerItemRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/OverlayRenderHelper.java @@ -19,13 +19,12 @@ import net.minecraft.world.storage.MapData; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.IItemRenderer; import net.minecraftforge.client.MinecraftForgeClient; -import noppes.npcs.controllers.data.SkinOverlayData; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import static net.minecraftforge.client.IItemRenderer.ItemRenderType.*; -public class RenderCNPCPlayerItemRenderer extends ItemRenderer { +public class OverlayRenderHelper extends ItemRenderer { private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); private static final ResourceLocation RES_MAP_BACKGROUND = new ResourceLocation("textures/map/map_background.png"); private static final ResourceLocation RES_UNDERWATER_OVERLAY = new ResourceLocation("textures/misc/underwater.png"); @@ -40,7 +39,7 @@ public class RenderCNPCPlayerItemRenderer extends ItemRenderer { /** The index of the currently held item (0-8, or -1 if not yet updated) */ private int equippedItemSlot = -1; - public RenderCNPCPlayerItemRenderer(Minecraft mc) { + public OverlayRenderHelper(Minecraft mc) { super(mc); this.mc = mc; } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index 9ed1d62d0..6d6916787 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -5,14 +5,19 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import noppes.npcs.client.Client; @@ -21,8 +26,13 @@ import noppes.npcs.controllers.data.SkinOverlayData; import org.lwjgl.opengl.GL11; import org.lwjgl.util.glu.Project; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.List; + public class RenderCNPCPlayer extends RenderPlayer { - public RenderCNPCPlayerItemRenderer itemRenderer = new RenderCNPCPlayerItemRenderer(Minecraft.getMinecraft()); + public OverlayRenderHelper itemRenderer = new OverlayRenderHelper(Minecraft.getMinecraft()); + public float tempRenderPartialTicks; private float debugCamFOV; private float prevDebugCamFOV; private float fovModifierHand; @@ -93,7 +103,7 @@ public class RenderCNPCPlayer extends RenderPlayer { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDisable(GL11.GL_BLEND); - Minecraft.getMinecraft().entityRenderer.enableLightmap((double)0); + Minecraft.getMinecraft().entityRenderer.enableLightmap((double) 0); RenderHelper.enableStandardItemLighting(); } @@ -119,8 +129,13 @@ public class RenderCNPCPlayer extends RenderPlayer { overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ )) return; - this.modelBipedMain.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); - postRenderOverlay(player); + try { + renderEquippedItemsJBRA(player, tempRenderPartialTicks); + } catch (Exception e) { + this.modelBipedMain.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_); + } finally { + postRenderOverlay(player); + } } } else if(player.getEntityData().hasKey("SkinOverlayData")) { Client.sendData(EnumPacketServer.SERVER_UPDATE_SKIN_OVERLAYS, new Object[0]); @@ -323,4 +338,684 @@ public class RenderCNPCPlayer extends RenderPlayer { Client.sendData(EnumPacketServer.SERVER_UPDATE_SKIN_OVERLAYS, new Object[0]); } } + + byte b(String n) { + return Byte.parseByte(n); + } + + protected void renderEquippedItemsJBRA(EntityPlayer player, float partialTick) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { + Minecraft mc = Minecraft.getMinecraft(); + Object data = null; + + Class renderPlayerJBRA = Class.forName("JinRyuu.JBRA.RenderPlayerJBRA"); + Class JBRAH = Class.forName("JinRyuu.JBRA.JBRAH"); + Class JRMCoreH = Class.forName("JinRyuu.JRMCore.JRMCoreH"); + Class JGConfigUltraInstinct = Class.forName("JinRyuu.JRMCore.server.config.dbc.JGConfigUltraInstinct"); + Class JRMCoreHDBC = Class.forName("JinRyuu.JRMCore.JRMCoreHDBC"); + Class ExtendedPlayer = Class.forName("JinRyuu.JRMCore.i.ExtendedPlayer"); + Class ItemVanity = Class.forName("JinRyuu.JRMCore.items.ItemVanity"); + Class ItemsDBC = Class.forName("JinRyuu.DragonBC.common.Items.ItemsDBC"); + Class JRMCoreConfig = Class.forName("JinRyuu.JRMCore.JRMCoreConfig"); + Class JRMCoreGuiScreen = Class.forName("JinRyuu.JRMCore.JRMCoreGuiScreen"); + Class ModelBipedDBC = Class.forName("JinRyuu.JBRA.ModelBipedDBC"); + Class JRMCoreHJYC = Class.forName("JinRyuu.JRMCore.JRMCoreHJYC"); + Class JGConfigClientSettings = Class.forName("JinRyuu.JRMCore.client.config.jrmc.JGConfigClientSettings"); + + Object playerRenderer = renderPlayerJBRA.cast(RenderManager.instance.getEntityRenderObject(player)); + + Object modelMain = renderPlayerJBRA.getField("modelMain").get(playerRenderer); + ModelBiped model = ((ModelBiped) modelMain); + + float headOffsetY = 0.0005F; + model.bipedHead.offsetY += headOffsetY; + + float armOffsetX = -0.00125F; + model.bipedLeftArm.offsetX += armOffsetX; + model.bipedRightArm.offsetX += -armOffsetX; + + float legOffsetX = -0.0005F; + float legOffsetY = -0.002F; + float legOffsetZ = 0.0F; + if (player.isSneaking()) { + legOffsetZ += -0.00075F; + } + model.bipedLeftLeg.offsetX += legOffsetX; + model.bipedRightLeg.offsetX += -legOffsetX; + model.bipedLeftLeg.offsetY += legOffsetY; + model.bipedRightLeg.offsetY += legOffsetY; + model.bipedLeftLeg.offsetZ += legOffsetZ; + model.bipedRightLeg.offsetZ += legOffsetZ; + + if ((Boolean) JBRAH.getMethod("JHDS").invoke(null)) { + data = JBRAH.getMethod("skinData",EntityPlayer.class).invoke(null,player); + } + + ItemStack itemstack = player.inventory.armorItemInSlot(3); + boolean doit = true; + ItemStack hair = player.inventory.armorItemInSlot(3); + if (hair != null) { + if ((Boolean) JRMCoreH.getMethod("DBC").invoke(null)) { + doit = true; + } else if ((Boolean) JRMCoreH.getMethod("NC").invoke(null) && itemstack.getItem() instanceof ItemArmor) { + if (hair.getItem().getUnlocalizedName().endsWith("Headband")) { + doit = false; + } + + if (hair.getItem().getUnlocalizedName().replaceAll("item.", "").startsWith("akatsuki")) { + doit = true; + } + } else { + doit = true; + } + } else { + doit = true; + } + + boolean dbc = (Boolean) JRMCoreH.getMethod("DBC").invoke(null); + boolean nc = (Boolean) JRMCoreH.getMethod("NC").invoke(null); + boolean saoc = (Boolean) JRMCoreH.getMethod("SAOC").invoke(null); + float age = (float) JRMCoreHJYC.getMethod("JYCAge",EntityPlayer.class).invoke(null,player); + int pl; + if (JRMCoreH.getField("plyrs").get(null) != null && ((String[]) JRMCoreH.getField("plyrs").get(null)).length > 0 && !player.isInvisible() && (Boolean)JRMCoreH.getMethod("dnn",int.class).invoke(null,1) && ((Boolean)JRMCoreH.getMethod("dnn",int.class).invoke(null,2) && (Boolean)JRMCoreH.getMethod("dnn",int.class).invoke(null,4) && (Boolean)JRMCoreH.getMethod("dnn",int.class).invoke(null,5) && (Boolean)JRMCoreH.getMethod("dnn",int.class).invoke(null,19) || !dbc && !saoc && !nc)) { + for(pl = 0; pl < ((String[]) JRMCoreH.getField("plyrs").get(null)).length; ++pl) { + if (((String[]) JRMCoreH.getField("plyrs").get(null))[pl].equals(player.getCommandSenderName())) { + String[] s = ((String[]) JRMCoreH.getField("data1").get(null))[pl].split(";"); + int powerType = Integer.parseInt(s[2]); + int race = Integer.parseInt(s[0]); + String[] dummy = new String[]{"0", "0", "0"}; + int rg = JRMCoreH.getField("data4").get(null) == null ? 0 : Integer.parseInt(((String[]) JRMCoreH.getField("data4").get(null))[pl].split(";")[0]); + String[] state = JRMCoreH.getField("data2").get(null) == null ? dummy : ((String[]) JRMCoreH.getField("data2").get(null))[pl].split(";"); + String dns = s[1]; + int classID = Integer.parseInt(s[3]); + int weight = Integer.parseInt(s[5].split(",")[0]); + int st = (Boolean) JRMCoreH.getMethod("rc_arc",int.class).invoke(null,race) && (Boolean) JRMCoreGuiScreen.getField("ufc").get(null) ? 6 : (powerType != 2 && race != 0 ? this.b(state[0]) : 0); + int stY = this.b(state[0]); + boolean saiOozar = (Boolean) JRMCoreH.getMethod("rSai",int.class).invoke(null,race) && (st == 7 || st == 8); + int gen = (Integer) JRMCoreH.getMethod("dnsGender",String.class).invoke(null,dns); + int haircol = (Integer) JRMCoreH.getMethod("dnsHairC",String.class).invoke(null,dns); + int hairback = (Integer) JRMCoreH.getMethod("dnsHairB",String.class).invoke(null,dns); + int breast = (Integer) JRMCoreH.getMethod("dnsBreast",String.class).invoke(null,dns); + int skintype = (Integer) JRMCoreH.getMethod("dnsSkinT",String.class).invoke(null,dns); + boolean iau = (Boolean) JRMCoreH.getMethod("rc_arc",int.class).invoke(null,race) && st == 6; + String dnsau = (String) JRMCoreH.getMethod("data",int.class, int.class, String.class).invoke(null,pl, 16, ""); + dnsau = dnsau.contains(";") ? dnsau.substring(1) : (((String[]) JRMCoreH.getField("plyrs").get(null))[pl].equals(mc.thePlayer.getCommandSenderName()) ? dnsau : ""); + int bodytype = skintype == 0 ? (Integer) JRMCoreH.getMethod("dnsBodyC1_0",String.class).invoke(null,dns) : (Integer) JRMCoreH.getMethod("dnsBodyT",String.class).invoke(null,dns); + int bodycm = skintype == 0 ? 0 : (iau ? (Integer) JRMCoreH.getMethod("dnsauCM",String.class).invoke(null,dnsau) : (Integer) JRMCoreH.getMethod("dnsBodyCM",String.class).invoke(null,dns)); + int bodyc1 = skintype == 0 ? 0 : (iau ? (Integer) JRMCoreH.getMethod("dnsauC1",String.class).invoke(null,dnsau) : (Integer) JRMCoreH.getMethod("dnsBodyC1",String.class).invoke(null,dns)); + int bodyc2 = skintype == 0 ? 0 : (iau ? (Integer) JRMCoreH.getMethod("dnsauC2",String.class).invoke(null,dnsau) : (Integer) JRMCoreH.getMethod("dnsBodyC2",String.class).invoke(null,dns)); + int bodyc3 = skintype == 0 ? 0 : (iau ? (Integer) JRMCoreH.getMethod("dnsauC3",String.class).invoke(null,dnsau) : (Integer) JRMCoreH.getMethod("dnsBodyC3",String.class).invoke(null,dns)); + int facen = skintype == 0 ? 0 : (Integer) JRMCoreH.getMethod("dnsFaceN",String.class).invoke(null,dns); + int facem = skintype == 0 ? 0 : (Integer) JRMCoreH.getMethod("dnsFaceM",String.class).invoke(null,dns); + int eyes = skintype == 0 ? 0 : (Integer) JRMCoreH.getMethod("dnsEyes",String.class).invoke(null,dns); + int eyec1 = skintype == 0 ? 0 : (Integer) JRMCoreH.getMethod("dnsEyeC1",String.class).invoke(null,dns); + int eyec2 = skintype == 0 ? 0 : (Integer) JRMCoreH.getMethod("dnsEyeC2",String.class).invoke(null,dns); + if (JRMCoreH.getField("data5").get(null) != null) { + ((String[])JRMCoreH.getField("data5").get(null))[pl].split(";"); + } + + HashMap playerData = new HashMap<>(); + for (int i = 0; i <= 31; i++) { + Object obj; + + if (i < 10) { + obj = JRMCoreH.getField("data" + i).get(null); + } else { + obj = JRMCoreH.getField("dat" + i).get(null); + } + + if (obj != null) { + playerData.put(i, ((String[]) obj)[pl].split(";")); + } + } + + int[] playerAttributes = new int[((int[])(JRMCoreH.getField("PlyrAttrbts").get(null))).length]; + String[] playerStatsStr = ((String[])(JRMCoreH.getField("dat14").get(null)))[pl].split(","); + + for(int i = 0; i < playerAttributes.length; ++i) { + playerAttributes[i] = Integer.parseInt(playerStatsStr[i]); + } + + byte release = Byte.parseByte(playerData.get(10)[0]); + float f1 = 0.9375F; + float f2 = 1.0F; + float f3 = 1.0F; + boolean noC = !(Boolean) JRMCoreH.getMethod("DBC").invoke(null); + + if ((int)JRMCoreH.getMethod("dnsGender",String.class).invoke(null,(String)JRMCoreH.getField("dns").get(null)) <= 1) { + f1 = 0.73F + (noC ? 0.27F : 0.0F); + } + + if ((int)JRMCoreH.getMethod("dnsGender",String.class).invoke(null,(String)JRMCoreH.getField("dns").get(null)) >= 2) { + f1 = 0.7F + (noC ? 0.27F : 0.0F); + } + + float yc = 1.0F; + float f1r; + if ((Boolean) JRMCoreH.getMethod("JYC").invoke(null)) { + f1r = age; + if (f1r <= 6.0F) { + yc = 0.5F; + } + + if (f1r > 6.0F && f1r <= 52.0F) { + yc = (3.0F - (1.0F + (1.0F - (f1r - 6.0F) / 46.0F))) * 0.5F; + } + + if (f1r > 53.0F) { + yc = 1.0F; + } + + yc = Math.max(yc, 0.54347825F); + } + + if ((Boolean) JRMCoreH.getMethod("DBC").invoke(null) && (Boolean) JRMCoreConfig.getField("sizes").get(null)) { + f1r = f1; + f1 += (float) JRMCoreHDBC.getMethod("DBCsizeBasedOnCns",int[].class).invoke(null, (Object) playerAttributes); + + if (!((Boolean) JRMCoreH.getMethod("isPowerTypeChakra",int.class).invoke(null,powerType))) { + f2 = (float) JRMCoreHDBC.getMethod("DBCsizeBasedOnRace",int.class,int.class).invoke(null, race, st); + f3 = (float) JRMCoreHDBC.getMethod("DBCsizeBasedOnRace2",int.class,int.class).invoke(null, race, st); + } + + if ((Boolean) JRMCoreH.getMethod("rSai",int.class).invoke(null,race) && (st == 7 || st == 8)) { + release = 50; + f1 = f1r; + } + + float f3a = (f3 - 1.0F) * (float)release * 0.02F + 1.0F; + f3 = f3a > f3 ? f3 : (f3 > 1.0F ? f3a : f3); + float f2a = (f2 - 1.0F) * (float)release * 0.02F + 1.0F; + f2 = f2 > 1.0F ? f2a : f2; + float f1a1 = (f1 - f1r) * (release <= 50 ? 0.25F : 0.5F); + float f1ac = f1a1 * (float)release * 0.02F; + f1 = f1 - f1r - f1a1 + f1ac + f1r; + String Fzn = (String) JRMCoreH.getMethod("getString",EntityPlayer.class,String.class).invoke(null,player,"jrmcFuzion"); + if (Fzn.contains(",")) { + String[] FznA = Fzn.split(","); + if (FznA.length == 3) { + boolean isp2 = FznA[1].equalsIgnoreCase(player.getCommandSenderName()); + if (isp2) { + f1 = 0.0F; + } + } + } + } + + float clientHeight = f1 * f3 * yc; + float clientWidth2 = f1 * f2 * f3 * yc; + + GL11.glTranslatef(0,-1.60859F * clientHeight + 1.50766F,0); + GL11.glScalef(clientWidth2 * 1.07F,clientHeight * 1.07F,clientWidth2 * 1.07F); + + boolean lg = (Boolean)JRMCoreH.getMethod("lgndb",int.class,int.class,int.class).invoke(null,pl, race, st); + boolean v = (Boolean)JRMCoreH.getMethod("StusEfctsClient",int.class,int.class).invoke(null,17, pl); + boolean l = (Boolean)JRMCoreH.getMethod("StusEfctsClient",int.class,int.class).invoke(null,19, pl); + int hc = haircol; + boolean ultra_instinct_color = false; + + byte CONFIG_UI_LEVELS = (Byte) JGConfigUltraInstinct.getField("CONFIG_UI_LEVELS").get(null); + + if ((Boolean) JRMCoreH.getMethod("DBC").invoke(null) && l && CONFIG_UI_LEVELS > 0) { + byte id = CONFIG_UI_LEVELS < this.b(state[1]) ? CONFIG_UI_LEVELS : this.b(state[1]); + int ultra_instinct_level = (Integer) JRMCoreH.getMethod("state2UltraInstinct",boolean.class,int.class).invoke(null,false, id); + ultra_instinct_color = ((Boolean[])JGConfigUltraInstinct.getField("CONFIG_UI_HAIR_WHITE").get(null))[ultra_instinct_level]; + } + + int suphcol = ((Boolean)JRMCoreH.getMethod("rc_sai",int.class).invoke(null,race)) && dbc ? ((int)JRMCoreHDBC.getMethod("col_fe",int.class,int.class,int.class,int.class,int.class,boolean.class,boolean.class,boolean.class,boolean.class).invoke(null,0, 0, powerType, race, st, v, lg, l, ultra_instinct_color)) : (dbc && l && ultra_instinct_color ? ((int)JRMCoreHDBC.getMethod("col_fe",int.class,int.class,int.class,int.class,int.class,boolean.class,boolean.class,boolean.class,boolean.class).invoke(null,0, 0, powerType, race, st, v, lg, l, ultra_instinct_color)) : 0); + int supecoll = dbc ? ((int)JRMCoreHDBC.getMethod("col_fe",int.class, int.class, int.class, int.class, int.class, boolean.class, boolean.class, boolean.class).invoke(null,1, eyec1, powerType, race, stY, v, lg, l)) : eyec1; + int supecolr = dbc ? ((int)JRMCoreHDBC.getMethod("col_fe",int.class, int.class, int.class, int.class, int.class, boolean.class, boolean.class, boolean.class).invoke(null,1, eyec2, powerType, race, stY, v, lg, l)) : eyec2; + String[] StE = JRMCoreH.getField("dat19").get(null) == null ? dummy : ((String[])JRMCoreH.getField("dat19").get(null))[pl].split(";"); + + byte ts = Byte.parseByte(StE[0]); + boolean mj = (boolean) JRMCoreH.getMethod("StusEfctsClient",int.class,int.class).invoke(null,12,pl); + boolean msk = (boolean) JRMCoreH.getMethod("StusEfctsClient",int.class,int.class).invoke(null,6,pl); + Object props = ExtendedPlayer.getMethod("get",EntityPlayer.class).invoke(null,player); + String dnsH = ((String)ExtendedPlayer.getMethod("getHairCode").invoke(props)).length() > 5 ? ((String)ExtendedPlayer.getMethod("getHairCode").invoke(props)) : ""; + dnsH = (String) JRMCoreH.getMethod("dnsHairG1toG2",String.class).invoke(null,dnsH); + + if ((Boolean) JRMCoreH.getMethod("DBC").invoke(null)) { + + boolean kk2 = (boolean) JRMCoreH.getMethod("StusEfctsMe",int.class).invoke(null,5); + renderPlayerJBRA.getField("kk").set(playerRenderer,this.b(state[1]) + 1); + + int kk = (int) renderPlayerJBRA.getField("kk").get(playerRenderer); + + + boolean rAccessible = renderPlayerJBRA.getField("r2").isAccessible(); + boolean gAccessible = renderPlayerJBRA.getField("g2").isAccessible(); + boolean bAccessible = renderPlayerJBRA.getField("b2").isAccessible(); + + renderPlayerJBRA.getField("r2").setAccessible(true); + renderPlayerJBRA.getField("g2").setAccessible(true); + renderPlayerJBRA.getField("b2").setAccessible(true); + + if (kk2) { + renderPlayerJBRA.getField("r2").set(null,(float)kk / 15.0F); + renderPlayerJBRA.getField("g2").set(null,-((float)kk / 15.0F)); + renderPlayerJBRA.getField("b2").set(null,-((float)kk / 15.0F)); + if ((float)renderPlayerJBRA.getField("r2").get(null) > 1.0F) { + renderPlayerJBRA.getField("r2").set(null,1.0F); + } + + if ((float)renderPlayerJBRA.getField("g2").get(null) < 0.0F) { + renderPlayerJBRA.getField("r2").set(null,0.0F); + } + + if ((float)renderPlayerJBRA.getField("b2").get(null) < 0.0F) { + renderPlayerJBRA.getField("r2").set(null,0.0F); + } + } else { + renderPlayerJBRA.getField("r2").set(null,0.0F); + renderPlayerJBRA.getField("g2").set(null,0.0F); + renderPlayerJBRA.getField("b2").set(null,0.0F); + } + + renderPlayerJBRA.getField("r2").setAccessible(rAccessible); + renderPlayerJBRA.getField("g2").setAccessible(gAccessible); + renderPlayerJBRA.getField("b2").setAccessible(bAccessible); + } + + GL11.glPushMatrix(); + int maxBody; + float h1; + if (race == 3 && dbc) { + int j = 5095183; + h1 = 1.0F; + ////renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodycm); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"N"); + + ////renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodycm); + ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + + ////renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodyc1); + //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + + + ////renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodyc2); + //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + + //GL11.glColor3f(h1 + (float)renderPlayerJBRA.getField("r2").get(null), h1 + (float)renderPlayerJBRA.getField("g2").get(null), h1 + (float)renderPlayerJBRA.getField("b2").get(null)); + //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodycm); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"FACENOSE"); + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodycm); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"FACEMOUTH"); + //GL11.glColor3f(1.0F + (float)renderPlayerJBRA.getField("r2").get(null), 1.0F + (float)renderPlayerJBRA.getField("g2").get(null), 1.0F + (float)renderPlayerJBRA.getField("b2").get(null)); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"EYEBASE"); + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,!((Boolean)JRMCoreH.getMethod("rc_sai",int.class).invoke(null,race)) && !((Boolean)JRMCoreHDBC.getMethod("godKiUserBase",int.class,int.class).invoke(null,race,stY)) && !l ? eyec1 : supecoll); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"EYELEFT"); + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,!((Boolean)JRMCoreH.getMethod("rc_sai",int.class).invoke(null,race)) && !((Boolean)JRMCoreHDBC.getMethod("godKiUserBase",int.class,int.class).invoke(null,race,stY)) && !l ? eyec2 : supecolr); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"EYERIGHT"); + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodycm); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"EYEBROW"); + } else { + if (race == 4 && dbc) { + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodycm); + + short TransFrHrn = ((short[]) JRMCoreH.getField("TransFrHrn").get(null))[st]; + + ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,(ts == 4 ? "n" : "") + "FR" + TransFrHrn); + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodyc1); + ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,(ts == 4 ? "n" : "") + "FR" + TransFrHrn); + + + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodyc1); + ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodyc2); + ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,(ts == 4 ? "n" : "") + "FR" + TransFrHrn); + + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodyc2); + //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodyc3); + ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,(ts == 4 ? "n" : "") + "FR" + TransFrHrn); + + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodyc3); + //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodycm); + //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + h1 = 1.0F; + //GL11.glColor3f(h1 + (float)renderPlayerJBRA.getField("r2").get(null), h1 + (float)renderPlayerJBRA.getField("g2").get(null), h1 + (float)renderPlayerJBRA.getField("b2").get(null)); + ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,(ts == 4 ? "n" : "") + "FR" + TransFrHrn); + + //GL11.glColor3f(h1 + (float)renderPlayerJBRA.getField("r2").get(null), h1 + (float)renderPlayerJBRA.getField("g2").get(null), h1 + (float)renderPlayerJBRA.getField("b2").get(null)); + //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodyc1); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"FACENOSE"); + if (st == 5 && msk) { + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodycm); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"FACEMOUTH"); + } else { + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodyc1); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"FACEMOUTH"); + } + + //GL11.glColor3f(1.0F + (float)renderPlayerJBRA.getField("r2").get(null), 1.0F + (float)renderPlayerJBRA.getField("g2").get(null), 1.0F + (float)renderPlayerJBRA.getField("b2").get(null)); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"EYEBASE"); + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,!((Boolean)JRMCoreH.getMethod("rc_sai",int.class).invoke(null,race)) && !((Boolean)JRMCoreHDBC.getMethod("godKiUserBase",int.class,int.class).invoke(null,race,stY)) && !l ? eyec1 : supecoll); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"EYELEFT"); + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,!((Boolean)JRMCoreH.getMethod("rc_sai",int.class).invoke(null,race)) && !((Boolean)JRMCoreHDBC.getMethod("godKiUserBase",int.class,int.class).invoke(null,race,stY)) && !l ? eyec2 : supecolr); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"EYERIGHT"); + } else { + int tailCol; + boolean bc; + if (saiOozar) { + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,skintype != 0 ? bodycm : 11374471); + ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + tailCol = race != 2 && bodytype == 0 ? 6498048 : bodytype; + maxBody = st != 0 && st != 7 ? (lg ? 10092390 : 16574610) : (skintype == 1 ? bodyc1 : tailCol); + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,maxBody); + //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + //GL11.glColor3f(1.0F + (float)renderPlayerJBRA.getField("r2").get(null), 1.0F + (float)renderPlayerJBRA.getField("g2").get(null), 1.0F + (float)renderPlayerJBRA.getField("b2").get(null)); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"EYEBASE"); + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,skintype != 0 ? bodycm : 11374471); + ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"OOZARU"); + } else if (skintype != 0) { + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodycm); + ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodycm); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"FACENOSE"); + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodycm); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"FACEMOUTH"); + //GL11.glColor3f(1.0F + (float)renderPlayerJBRA.getField("r2").get(null), 1.0F + (float)renderPlayerJBRA.getField("g2").get(null), 1.0F + (float)renderPlayerJBRA.getField("b2").get(null)); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"EYEBASE"); + if (supecoll > 0) { + if (powerType == 2 && classID == 1) { + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,15590377); + } else if (powerType == 2 && classID == 2 && stY > 0) { + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,13828096); + } else { + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,!dbc || !((Boolean)JRMCoreH.getMethod("rc_sai",int.class).invoke(null,race)) && !((Boolean)JRMCoreHDBC.getMethod("godKiUserBase",int.class,int.class).invoke(null,race,stY)) && !l ? eyec1 : supecoll); + } + + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"EYELEFT"); + } + + if (supecolr > 0) { + if (powerType == 2 && classID == 1) { + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,15590377); + } else if (powerType == 2 && classID == 2 && stY > 0) { + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,13828096); + } else { + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,!dbc || !((Boolean)JRMCoreH.getMethod("rc_sai",int.class).invoke(null,race)) && !((Boolean)JRMCoreHDBC.getMethod("godKiUserBase",int.class,int.class).invoke(null,race,stY)) && !l ? eyec2 : supecolr); + } + + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"EYERIGHT"); + } + + if (race != 1 && race != 2) { + bc = false; + } else if (Integer.parseInt(state[0]) != 6) { + bc = false; + } else { + bc = true; + } + + if (!bc) { + if (l && ultra_instinct_color) { + //renderPlayerJBRA.getMethod("glColor3f",int.class,float.class).invoke(null,15790320, age); + } else if ((race == 1 || race == 2) && st != 0) { + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,suphcol); + } else { + //renderPlayerJBRA.getMethod("glColor3f",int.class,float.class).invoke(null,haircol, age); + } + } else { + //GL11.glColor3f(1.0F, 1.0F, 1.0F); + } + + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"EYEBROW"); + } + + if (((Boolean)JRMCoreH.getMethod("rc_sai",int.class).invoke(null,race)) && dbc) { + tailCol = race != 2 && bodytype == 0 ? 6498048 : bodytype; + maxBody = st != 0 && st != 7 && st != 14 ? suphcol : (skintype == 1 ? bodyc1 : tailCol); + if ((Boolean) JRMCoreH.getMethod("rSai",int.class).invoke(null,race) && maxBody == 6498048) { + if (st == 14) { + maxBody = (Boolean) JRMCoreH.getMethod("func_26n6").invoke(null) ? 13292516 : 14292268; + } else if (l && ultra_instinct_color) { + maxBody = 15790320; + } + } + + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,maxBody); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,ts != 0 && ts != -1 ? (ts == 1 ? "SJT2" : "") : "SJT1"); + } + + h1 = 1.0F; + if (!saiOozar) { + if (skintype == 0 && gen >= 1) { + //GL11.glColor3f(h1 + (float)renderPlayerJBRA.getField("r2").get(null), h1 + (float)renderPlayerJBRA.getField("g2").get(null), h1 + (float)renderPlayerJBRA.getField("b2").get(null)); + //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + } else if ((Boolean) JBRAH.getMethod("JHDS").invoke(null) && (Boolean) JBRAH.getMethod("getSkinHas",Object.class).invoke(null,data) && skintype == 0) { + //GL11.glColor3f(h1 + (float)renderPlayerJBRA.getField("r2").get(null), h1 + (float)renderPlayerJBRA.getField("g2").get(null), h1 + (float)renderPlayerJBRA.getField("b2").get(null)); + //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + } + } + + boolean var10000; + label964: { + label963: { + if (l) { + if (!ultra_instinct_color) { + break label963; + } + } else if (st == 0) { + break label963; + } + + if (st != 14) { + var10000 = true; + break label964; + } + } + + var10000 = false; + } + + bc = var10000; + String s1; + if ((hairback == 8 || hairback == 9) && (st == 0 || st == 1)) { + hc = bc ? suphcol : haircol; + s1 = hairback == 8 ? "c2" : "c1"; + } else if (hairback >= 0 && hairback <= 12) { + hc = bc ? suphcol : (st == 14 && (Boolean) JRMCoreH.getMethod("func_26n6").invoke(null) ? 13292516 : haircol); + s1 = st == 0 ? "normall" : "superall"; + } + + if (bc) { + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,hc); + } else { + //renderPlayerJBRA.getMethod("glColor3f",int.class,float.class).invoke(null,hc,age); + } + + boolean scouter = false; + boolean helmet = false; + if (itemstack != null) { + Item item = itemstack.getItem(); ; + if ((Boolean) JRMCoreH.getMethod("DBC").invoke(null) && item instanceof ItemArmor) { + ItemArmor itemarmor = (ItemArmor)item; + helmet = true; + } + } + + boolean vanity_head = false; + String[][] slot_vanity_num = new String[8][]; + int[] slot_van = new int[8]; + + for(int i = 0; i < 8; ++i) { + slot_vanity_num[i] = s[8 + i].split(","); + slot_van[i] = Integer.parseInt(slot_vanity_num[i][0]); + if (!vanity_head && slot_van[i] > 0) { + new Item(); + Item vanity_check = Item.getItemById(slot_van[i]); + if (ItemVanity.isInstance(vanity_check) && (int)(ItemVanity.getField("armorType").get(ItemVanity.cast(vanity_check))) == 5) { + int var90 = slot_van[i]; + Item var10001 = (Item)ItemsDBC.getField("Coat_2").get(null); + if (var90 != Item.getIdFromItem((Item)ItemsDBC.getField("Coat_2").get(null))) { + var90 = slot_van[i]; + var10001 = (Item)ItemsDBC.getField("Coat").get(null); + if (var90 != Item.getIdFromItem((Item)ItemsDBC.getField("Coat").get(null))) { + vanity_head = true; + } + } + } + } + } + + if (!saiOozar) { + boolean dhhwho = !((Boolean) JRMCoreConfig.getField("HHWHO").get(null)) || !helmet && !vanity_head || scouter; + if (hairback == 12 && dhhwho && dnsH.length() > 3) { + if (player == mc.thePlayer && (Integer)JRMCoreGuiScreen.getField("hairPreview").get(null) > 0) { + st = ((int[])JRMCoreGuiScreen.getField("hairPreviewStates").get(null))[(Integer)JRMCoreGuiScreen.getField("hairPreview").get(null)]; + } + + if (st == 6) { + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"" + ((String[])JRMCoreH.getField("HairsT").get(null))[6] + ((String[])JRMCoreH.getField("Hairs").get(null))[0]); + } else if (st == 14) { + //ModelBipedDBC.getMethod("renderHairsV2",float.class,String.class,float.class,int.class,int.class,int.class,int.class,renderPlayerJBRA).invoke(modelMain,0.0625F, "373852546750347428545480193462285654801934283647478050340147507467501848505072675018255250726750183760656580501822475071675018255050716750189730327158501802475071675018973225673850189765616160501820414547655019545654216550195754542165501920475027655019943669346576193161503065231900475030655019406534276538199465393460501997654138655019976345453950189760494941501897615252415018976354563850189763494736501897614949395018976152523950189763525234501897584749395018976150493850189760545234501897585250415018885445474550189754475041501897545250435018885454523950185143607861501897415874585018514369196150185147768078391865525680565018974356806150188843567861501868396374615018975056805650189750568056501885582374615018975823726150187149568054501877495680565018774950785650189163236961501820", 0.0F, 0, 0, pl, race, playerRenderer); + } else { + //ModelBipedDBC.getMethod("renderHairsV2",float.class,String.class,float.class,int.class,int.class,int.class,int.class,renderPlayerJBRA).invoke(modelMain,0.0625F, dnsH, 0.0F, st, rg, pl, race, playerRenderer); + } + } else if (hairback == 10) { + //GL11.glColor3f(h1 + (float)renderPlayerJBRA.getField("r2").get(null), h1 + (float)renderPlayerJBRA.getField("g2").get(null), h1 + (float)renderPlayerJBRA.getField("b2").get(null)); + //ModelBipedDBC.getMethod("renderHeadwear",float.class).invoke(modelMain,0.0625F); + } else if (dhhwho) { + if (st == 14) { + //ModelBipedDBC.getMethod("renderHairsV2",float.class,String.class,float.class,int.class,int.class,int.class,int.class,renderPlayerJBRA).invoke(modelMain,0.0625F, "373852546750347428545480193462285654801934283647478050340147507467501848505072675018255250726750183760656580501822475071675018255050716750189730327158501802475071675018973225673850189765616160501820414547655019545654216550195754542165501920475027655019943669346576193161503065231900475030655019406534276538199465393460501997654138655019976345453950189760494941501897615252415018976354563850189763494736501897614949395018976152523950189763525234501897584749395018976150493850189760545234501897585250415018885445474550189754475041501897545250435018885454523950185143607861501897415874585018514369196150185147768078391865525680565018974356806150188843567861501868396374615018975056805650189750568056501885582374615018975823726150187149568054501877495680565018774950785650189163236961501820", 0.0F, 0, 0, pl, race, playerRenderer); + } else { + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"" + ((String[])JRMCoreH.getField("HairsT").get(null))[st] + ((String[])JRMCoreH.getField("Hairs").get(null))[hairback]); + } + } + + if (st == 14) { + tailCol = race != 2 && bodytype == 0 ? 6498048 : bodytype; + tailCol = (Boolean) JRMCoreH.getMethod("func_26n6").invoke(null) ? 13292516 : tailCol; + int jx = skintype == 1 ? bodyc1 : tailCol; + if ((Boolean) JRMCoreH.getMethod("rSai",int.class).invoke(null,race) && jx == 6498048 && st == 14) { + if ((Boolean) JRMCoreH.getMethod("func_26n6").invoke(null)) { + jx = 13292516; + } else { + jx = 14292268; + } + } + + //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,jx); + //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + } + } + } + } + + /*if (mj) { + //GL11.glColor3f(1.0F + (float)renderPlayerJBRA.getField("r2").get(null), 1.0F + (float)renderPlayerJBRA.getField("g2").get(null), 1.0F + (float)renderPlayerJBRA.getField("b2").get(null)); + ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"EYERIGHT"); + }*/ + + String[] stri; + if (dbc) { + stri = new String[]{"wshell", "whandleg"}; + if (weight >= 0 && weight < stri.length) { + String[] wloc = new String[]{"roshiShell", "weightBands"}; + //GL11.glColor3f(1.0F + (float)renderPlayerJBRA.getField("r2").get(null), 1.0F + (float)renderPlayerJBRA.getField("g2").get(null), 1.0F + (float)renderPlayerJBRA.getField("b2").get(null)); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,stri[weight]); + } + } + + if ((Boolean) JGConfigClientSettings.getField("CLIENT_DA19").get(null) && ((Boolean) JRMCoreH.getMethod("DBC").invoke(null) || (Boolean) JRMCoreH.getMethod("NC").invoke(null))) { + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glDisable(2896); + GL11.glBlendFunc(770, 771); + GL11.glAlphaFunc(516, 0.003921569F); + GL11.glDepthMask(false); + int[] PlyrAttrbts = new int[((int[])(JRMCoreH.getField("PlyrAttrbts").get(null))).length]; + stri = ((String[])(JRMCoreH.getField("dat14").get(null)))[pl].split(","); + + for(maxBody = 0; maxBody < PlyrAttrbts.length; ++maxBody) { + PlyrAttrbts[maxBody] = Integer.parseInt(stri[maxBody]); + } + + maxBody = (int) JRMCoreH.getMethod("stat",Entity.class, int.class, int.class, int.class, int.class, int.class, int.class, float.class).invoke(null,player, 2, powerType, 2, PlyrAttrbts[2], race, classID, 0.0F); + + int curBody = Integer.parseInt((String)JRMCoreH.getMethod("data",String.class,int.class,String.class).invoke(null,player.getCommandSenderName(), 8, "200")); + float one = (float)maxBody / 100.0F; + int perc = (int)((float)curBody / one); + if (perc < 70) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + } + + if (perc < 55) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + } + + if (perc < 35) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + } + + if (perc < 20) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); + } + + GL11.glDepthMask(true); + GL11.glEnable(2896); + GL11.glDisable(3042); + GL11.glPopMatrix(); + if ((Boolean) JRMCoreH.getMethod("NC").invoke(null) && powerType == 2) { + if (classID == 1 && stY > 0) { + //GL11.glColor3f(1.0F + (float)renderPlayerJBRA.getField("r2").get(null), 1.0F + (float)renderPlayerJBRA.getField("g2").get(null), 1.0F + (float)renderPlayerJBRA.getField("b2").get(null)); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"EYERIGHT"); + } else if (classID == 2 && stY > 0) { + int doujutsuID = (stY - 1) / 3 + 1; + if (doujutsuID < 1) { + doujutsuID = 1; + } else if (doujutsuID > 3) { + doujutsuID = 3; + } + + //GL11.glColor3f(1.0F + (float)renderPlayerJBRA.getField("r2").get(null), 1.0F + (float)renderPlayerJBRA.getField("g2").get(null), 1.0F + (float)renderPlayerJBRA.getField("b2").get(null)); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"EYERIGHT"); + } + } + } + + GL11.glPopMatrix(); + doit = false; + break; + } + } + } + + /*if (((String[]) JRMCoreH.getField("plyrs").get(null)) != null && ((String[]) JRMCoreH.getField("plyrs").get(null)).length > 0 && !player.isInvisible() && (Boolean)JRMCoreH.getMethod("dnn",int.class).invoke(null,13)) { + for(pl = 0; pl < ((String[]) JRMCoreH.getField("plyrs").get(null)).length; ++pl) { + if (((String[]) JRMCoreH.getField("plyrs").get(null))[pl].equals(player.getCommandSenderName()) && (Boolean)JRMCoreH.getMethod("aliveState",int.class).invoke(null,pl)) { + GL11.glPushMatrix(); + //GL11.glColor3f(1.0F + (float)renderPlayerJBRA.getField("r2").get(null), 1.0F + (float)renderPlayerJBRA.getField("g2").get(null), 1.0F + (float)renderPlayerJBRA.getField("b2").get(null)); + ModelBipedDBC.getMethod("renderHalo",float.class).invoke(modelMain,0.0625F); + GL11.glPopMatrix(); + break; + } + } + }*/ + + /*if (doit && !player.isInvisible() && player.func_152123_o()) { + GL11.glPushMatrix(); + ModelBipedDBC.getMethod("renderHeadwear",float.class).invoke(modelMain,0.0625F); + GL11.glPopMatrix(); + }*/ + model.bipedHead.offsetY -= headOffsetY; + + model.bipedLeftArm.offsetX -= armOffsetX; + model.bipedRightArm.offsetX -= -armOffsetX; + + model.bipedLeftLeg.offsetX -= legOffsetX; + model.bipedRightLeg.offsetX -= -legOffsetX; + model.bipedLeftLeg.offsetY -= legOffsetY; + model.bipedRightLeg.offsetY -= legOffsetY; + model.bipedLeftLeg.offsetZ -= legOffsetZ; + model.bipedRightLeg.offsetZ -= legOffsetZ; + } } From fd9e0d8ead4e1398f70955f82a19c897ab3067c7 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Sun, 22 May 2022 05:08:43 -0500 Subject: [PATCH 61/75] Skin overlays when viewed in first person now correctly apply moving texture updates. --- .../client/renderer/RenderCNPCPlayer.java | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index 6d6916787..72a7dee68 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -5,7 +5,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.model.ModelBiped; -import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.RenderHelper; @@ -28,7 +27,6 @@ import org.lwjgl.util.glu.Project; import java.lang.reflect.InvocationTargetException; import java.util.HashMap; -import java.util.List; public class RenderCNPCPlayer extends RenderPlayer { public OverlayRenderHelper itemRenderer = new OverlayRenderHelper(Minecraft.getMinecraft()); @@ -47,7 +45,7 @@ public class RenderCNPCPlayer extends RenderPlayer { this.setRenderManager(RenderManager.instance); } - private boolean preRenderOverlay(float partialTickTime, EntityPlayer player, ResourceLocation overlayLocation, boolean glow, + private boolean preRenderOverlay(EntityPlayer player, ResourceLocation overlayLocation, boolean glow, float alpha, float size, float speedX, float speedY, float scaleX, float scaleY, float offsetX, float offsetY, float offsetZ) { try { @@ -56,15 +54,13 @@ public class RenderCNPCPlayer extends RenderPlayer { return false; } - if (partialTickTime == 0) { - if (!Client.entitySkinOverlayTicks.containsKey(player.getUniqueID())) { - Client.entitySkinOverlayTicks.put(player.getUniqueID(), 1L); - } else { - long ticks = Client.entitySkinOverlayTicks.get(player.getUniqueID()); - Client.entitySkinOverlayTicks.put(player.getUniqueID(), ticks + 1); - } - partialTickTime = Client.entitySkinOverlayTicks.get(player.getUniqueID());; + if (!Client.entitySkinOverlayTicks.containsKey(player.getUniqueID())) { + Client.entitySkinOverlayTicks.put(player.getUniqueID(), 1L); + } else { + long ticks = Client.entitySkinOverlayTicks.get(player.getUniqueID()); + Client.entitySkinOverlayTicks.put(player.getUniqueID(), ticks + 1); } + float partialTickTime = Client.entitySkinOverlayTicks.get(player.getUniqueID()); // Overlay & Glow if (glow) { @@ -124,7 +120,7 @@ public class RenderCNPCPlayer extends RenderPlayer { } } - if (!preRenderOverlay(0, player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size, + if (!preRenderOverlay(player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size, overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY, overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ )) @@ -324,7 +320,7 @@ public class RenderCNPCPlayer extends RenderPlayer { } } - if (!preRenderOverlay(partialTickTime, player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size, + if (!preRenderOverlay(player, overlayData.location, overlayData.glow, overlayData.alpha, overlayData.size, overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY, overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ )) @@ -656,18 +652,18 @@ public class RenderCNPCPlayer extends RenderPlayer { ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,(ts == 4 ? "n" : "") + "FR" + TransFrHrn); //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodyc1); - ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,(ts == 4 ? "n" : "") + "FR" + TransFrHrn); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,(ts == 4 ? "n" : "") + "FR" + TransFrHrn); //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodyc1); ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodyc2); - ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,(ts == 4 ? "n" : "") + "FR" + TransFrHrn); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,(ts == 4 ? "n" : "") + "FR" + TransFrHrn); //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodyc2); //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodyc3); - ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,(ts == 4 ? "n" : "") + "FR" + TransFrHrn); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,(ts == 4 ? "n" : "") + "FR" + TransFrHrn); //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodyc3); //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); @@ -676,7 +672,7 @@ public class RenderCNPCPlayer extends RenderPlayer { //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); h1 = 1.0F; //GL11.glColor3f(h1 + (float)renderPlayerJBRA.getField("r2").get(null), h1 + (float)renderPlayerJBRA.getField("g2").get(null), h1 + (float)renderPlayerJBRA.getField("b2").get(null)); - ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,(ts == 4 ? "n" : "") + "FR" + TransFrHrn); + //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,(ts == 4 ? "n" : "") + "FR" + TransFrHrn); //GL11.glColor3f(h1 + (float)renderPlayerJBRA.getField("r2").get(null), h1 + (float)renderPlayerJBRA.getField("g2").get(null), h1 + (float)renderPlayerJBRA.getField("b2").get(null)); //ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); From d93ffc859c104d260fea78eaec274ce051ae6e15 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Sun, 22 May 2022 05:14:13 -0500 Subject: [PATCH 62/75] Skin overlays render on top of Namekian antennae now. --- src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index 72a7dee68..12ae28c55 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -618,7 +618,7 @@ public class RenderCNPCPlayer extends RenderPlayer { int j = 5095183; h1 = 1.0F; ////renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodycm); - //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"N"); + ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,"N"); ////renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,bodycm); ModelBipedDBC.getMethod("renderBody",float.class).invoke(modelMain,0.0625F); From 40fce6373445da345590385a919cef56807630bf Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Sun, 22 May 2022 05:17:01 -0500 Subject: [PATCH 63/75] Skin overlays render on top of Saiyan tails. --- src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index 12ae28c55..6d864e890 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -774,7 +774,7 @@ public class RenderCNPCPlayer extends RenderPlayer { } //renderPlayerJBRA.getMethod("glColor3f",int.class).invoke(null,maxBody); - //ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,ts != 0 && ts != -1 ? (ts == 1 ? "SJT2" : "") : "SJT1"); + ModelBipedDBC.getMethod("renderHairs",float.class,String.class).invoke(modelMain,0.0625F,ts != 0 && ts != -1 ? (ts == 1 ? "SJT2" : "") : "SJT1"); } h1 = 1.0F; From 6fa5d0d8de0ed13ca45c30953b17fc7011f34866 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Mon, 23 May 2022 00:45:32 -0500 Subject: [PATCH 64/75] Improved alpha blending for skin overlays --- .../java/noppes/npcs/client/renderer/RenderCNPCPlayer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index 6d864e890..23122927e 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -67,7 +67,8 @@ public class RenderCNPCPlayer extends RenderPlayer { GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LIGHTING); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); Minecraft.getMinecraft().entityRenderer.disableLightmap((double)0); RenderHelper.disableStandardItemLighting(); } @@ -99,6 +100,7 @@ public class RenderCNPCPlayer extends RenderPlayer { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDisable(GL11.GL_BLEND); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); Minecraft.getMinecraft().entityRenderer.enableLightmap((double) 0); RenderHelper.enableStandardItemLighting(); } @@ -362,7 +364,7 @@ public class RenderCNPCPlayer extends RenderPlayer { Object modelMain = renderPlayerJBRA.getField("modelMain").get(playerRenderer); ModelBiped model = ((ModelBiped) modelMain); - float headOffsetY = 0.0005F; + float headOffsetY = 0.00051F; model.bipedHead.offsetY += headOffsetY; float armOffsetX = -0.00125F; From 6220a8ce1434d08515a6969fe67ab800c41f6a8e Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Mon, 23 May 2022 20:41:32 -0500 Subject: [PATCH 65/75] -Overlays for players and NPCs are now grouped in an "overlay handler" object, similar to how you retrieve timers. -Fixed client NPC overlay updates. --- src/main/java/noppes/npcs/DataDisplay.java | 60 ++------------ .../noppes/npcs/ScriptPlayerEventHandler.java | 4 +- src/main/java/noppes/npcs/client/Client.java | 2 - .../java/noppes/npcs/client/NoppesUtil.java | 17 +--- .../client/gui/GuiNpcTextureOverlays.java | 8 +- .../client/gui/mainmenu/GuiNpcDisplay.java | 6 +- .../client/gui/model/GuiCreationScreen.java | 4 +- .../client/gui/model/GuiEntitySelection.java | 2 +- .../client/renderer/RenderNPCInterface.java | 6 +- .../noppes/npcs/controllers/PlayerData.java | 4 + .../controllers/data/SkinOverlayData.java | 57 +++++++++++++ .../npcs/entity/data/DataSkinOverlays.java | 82 +++++++++++++++++++ .../noppes/npcs/entity/data/DataTimers.java | 2 +- .../npcs/entity/old/EntityNPCEnderman.java | 4 +- .../java/noppes/npcs/scripted/NpcAPI.java | 1 - .../npcs/scripted/entity/ScriptNpc.java | 19 ++--- .../npcs/scripted/entity/ScriptPlayer.java | 61 ++------------ .../interfaces/entity/ICustomNpc.java | 5 +- .../scripted/interfaces/entity/IPlayer.java | 5 +- .../interfaces/handler/IOverlayHandler.java | 18 ++++ 20 files changed, 203 insertions(+), 164 deletions(-) create mode 100644 src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java create mode 100644 src/main/java/noppes/npcs/scripted/interfaces/handler/IOverlayHandler.java diff --git a/src/main/java/noppes/npcs/DataDisplay.java b/src/main/java/noppes/npcs/DataDisplay.java index 0afd70fd6..70f4fbda5 100644 --- a/src/main/java/noppes/npcs/DataDisplay.java +++ b/src/main/java/noppes/npcs/DataDisplay.java @@ -10,6 +10,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.util.StringUtils; import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.entity.data.DataSkinOverlays; import noppes.npcs.scripted.interfaces.ISkinOverlay; import noppes.npcs.util.ValueUtil; @@ -34,7 +35,7 @@ public class DataDisplay { public String texture = "customnpcs:textures/entity/humanmale/Steve.png"; public String cloakTexture = ""; - public HashMap skinOverlays = new HashMap<>(); + public DataSkinOverlays skinOverlayData; public long overlayRenderTicks = 0; public String glowTexture = ""; @@ -59,6 +60,7 @@ public class DataDisplay { public DataDisplay(EntityNPCInterface npc){ this.npc = npc; markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length-1); + skinOverlayData = new DataSkinOverlays(npc); name = getRandomName(); } @@ -66,30 +68,6 @@ public class DataDisplay { return CustomNpcs.MARKOV_GENERATOR[markovGeneratorId].fetch(markovGender); } - public NBTTagCompound writeOverlaysToNBT(NBTTagCompound nbttagcompound) { - NBTTagList overlayList = new NBTTagList(); - if (!npc.display.skinOverlays.isEmpty()) { - for (Map.Entry overlayData : npc.display.skinOverlays.entrySet()) { - NBTTagCompound compound = new NBTTagCompound(); - compound.setInteger("SkinOverlayID", overlayData.getKey()); - compound.setString("SkinOverlayTexture", overlayData.getValue().getTexture()); - compound.setBoolean("SkinOverlayGlow", overlayData.getValue().getGlow()); - compound.setFloat("SkinOverlayAlpha", overlayData.getValue().getAlpha()); - compound.setFloat("SkinOverlaySize", overlayData.getValue().getSize()); - compound.setFloat("SkinOverlaySpeedX", overlayData.getValue().getSpeedX()); - compound.setFloat("SkinOverlaySpeedY", overlayData.getValue().getSpeedY()); - compound.setFloat("SkinOverlayScaleX", overlayData.getValue().getScaleX()); - compound.setFloat("SkinOverlayScaleY", overlayData.getValue().getScaleY()); - compound.setFloat("SkinOverlayOffsetX", overlayData.getValue().getOffsetX()); - compound.setFloat("SkinOverlayOffsetY", overlayData.getValue().getOffsetY()); - compound.setFloat("SkinOverlayOffsetZ", overlayData.getValue().getOffsetZ()); - overlayList.appendTag(compound); - } - } - nbttagcompound.setTag("SkinOverlayData",overlayList); - return nbttagcompound; - } - public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { nbttagcompound.setString("Name", name); nbttagcompound.setInteger("MarkovGeneratorId", markovGeneratorId); @@ -101,7 +79,7 @@ public class DataDisplay { nbttagcompound.setByte("UsingSkinUrl", skinType); nbttagcompound.setString("GlowTexture", glowTexture); - nbttagcompound = writeOverlaysToNBT(nbttagcompound); + nbttagcompound = skinOverlayData.writeToNBT(nbttagcompound); if (this.playerProfile != null) { @@ -162,17 +140,7 @@ public class DataDisplay { if (!nbttagcompound.hasKey("SkinOverlayData") && !glowTexture.isEmpty()) { NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("SkinOverlayID", 0); //unique glow texture ID - compound.setString("SkinOverlayTexture", glowTexture); - compound.setBoolean("SkinOverlayGlow", true); - compound.setFloat("SkinOverlayAlpha", 1.0F); - compound.setFloat("SkinOverlaySize", 1.0F); - compound.setFloat("SkinOverlaySpeedX", 0.0F); - compound.setFloat("SkinOverlaySpeedY", 0.0F); - compound.setFloat("SkinOverlayScaleX", 1.0F); - compound.setFloat("SkinOverlayScaleY", 1.0F); - compound.setFloat("SkinOverlayOffsetX", 0.0F); - compound.setFloat("SkinOverlayOffsetY", 0.0F); - compound.setFloat("SkinOverlayOffsetZ", 0.0F); + (new SkinOverlayData(glowTexture)).writeToNBT(nbttagcompound); if (!nbttagcompound.hasKey("SkinOverlayData")) { NBTTagList tagList = new NBTTagList(); @@ -184,23 +152,7 @@ public class DataDisplay { } } - NBTTagList skinOverlayList = nbttagcompound.getTagList("SkinOverlayData",10); - for (int i = 0; i < skinOverlayList.tagCount(); i++) { - int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID"); - String tagString = skinOverlayList.getCompoundTagAt(i).getString("SkinOverlayTexture"); - boolean glow = skinOverlayList.getCompoundTagAt(i).getBoolean("SkinOverlayGlow"); - float alpha = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayAlpha"); - float size = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySize"); - float speedX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySpeedX"); - float speedY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySpeedY"); - float scaleX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayScaleX"); - float scaleY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayScaleY"); - float offsetX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetX"); - float offsetY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetY"); - float offsetZ = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetZ"); - - skinOverlays.put(tagID,new SkinOverlayData(tagString,glow,alpha,size,speedX,speedY,scaleX,scaleY,offsetX,offsetY,offsetZ)); - } + skinOverlayData.readFromNBT(nbttagcompound); modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE); if(modelSize > CustomNpcs.NpcSizeLimit) diff --git a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java index 529013059..cf8a930c7 100644 --- a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java @@ -434,14 +434,14 @@ public class ScriptPlayerEventHandler { EventHooks.onPlayerLogin(handler, scriptPlayer); //Loads other players' and own player's skin overlays if they have them + /* List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; for (EntityPlayerMP playerMP : list) { if (playerMP.getEntityData().hasKey("SkinOverlayData")) { NBTTagCompound data = new NBTTagCompound(); data.setTag("SkinOverlayData",playerMP.getEntityData().getTagList("SkinOverlayData",10)); - Server.sendData(playerMP, EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS, data); } - } + }*/ } } diff --git a/src/main/java/noppes/npcs/client/Client.java b/src/main/java/noppes/npcs/client/Client.java index b09ea4fb2..94343800a 100644 --- a/src/main/java/noppes/npcs/client/Client.java +++ b/src/main/java/noppes/npcs/client/Client.java @@ -7,8 +7,6 @@ import java.io.IOException; import java.util.HashMap; import java.util.UUID; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; import noppes.npcs.CustomNpcs; import noppes.npcs.Server; import noppes.npcs.client.gui.customoverlay.OverlayCustom; diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index 2dfd659bd..b59d27fe9 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -13,8 +13,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -39,7 +37,6 @@ import noppes.npcs.controllers.Dialog; import noppes.npcs.controllers.DialogController; import noppes.npcs.controllers.Quest; import noppes.npcs.controllers.data.SkinOverlayData; -import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.Sys; @@ -81,19 +78,7 @@ public class NoppesUtil { for (int i = 0; i < skinOverlayList.tagCount(); i++) { int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID"); - String tagString = skinOverlayList.getCompoundTagAt(i).getString("SkinOverlayTexture"); - boolean glow = skinOverlayList.getCompoundTagAt(i).getBoolean("SkinOverlayGlow"); - float alpha = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayAlpha"); - float size = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySize"); - float speedX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySpeedX"); - float speedY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlaySpeedY"); - float scaleX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayScaleX"); - float scaleY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayScaleY"); - float offsetX = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetX"); - float offsetY = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetY"); - float offsetZ = skinOverlayList.getCompoundTagAt(i).getFloat("SkinOverlayOffsetZ"); - - skinOverlays.put(tagID,new SkinOverlayData(tagString,glow,alpha,size,speedX,speedY,scaleX,scaleY,offsetX,offsetY,offsetZ)); + skinOverlays.put(tagID, (SkinOverlayData) SkinOverlayData.overlayFromNBT(skinOverlayList.getCompoundTagAt(i))); } Client.skinOverlays.put(player.getUniqueID(), skinOverlays); } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java b/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java index e7166693d..7a1d7dd0d 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java @@ -12,14 +12,14 @@ import org.lwjgl.opengl.GL11; public class GuiNpcTextureOverlays extends GuiNpcSelectionInterface{ public GuiNpcTextureOverlays(EntityNPCInterface npc,GuiScreen parent){ //super(npc, parent, npc.display.glowTexture.isEmpty()?"customnpcs:textures/overlays/":npc.display.glowTexture); - super(npc, parent, npc.display.skinOverlays.containsKey(0) ? npc.display.skinOverlays.get(0).getTexture() : ""); + super(npc, parent, npc.display.skinOverlayData.overlayList.containsKey(0) ? npc.display.skinOverlayData.overlayList.get(0).getTexture() : ""); title = "Select Overlay"; this.parent = parent; } public void initGui(){ super.initGui(); - String str = npc.display.skinOverlays.containsKey(0) ? npc.display.skinOverlays.get(0).getTexture() : ""; + String str = npc.display.skinOverlayData.overlayList.containsKey(0) ? npc.display.skinOverlayData.overlayList.get(0).getTexture() : ""; int index = str.lastIndexOf("/"); if(index > 0){ String asset = str.substring(index + 1); @@ -79,8 +79,8 @@ public class GuiNpcTextureOverlays extends GuiNpcSelectionInterface{ //npc.display.glowTexture = assets.getAsset(slot.selected); npc.textureGlowLocation = null; - npc.display.skinOverlays.put(0,new SkinOverlayData( - assets.getAsset(slot.selected), true, 0.8F, 1.0F, 0.0F, 0.0F, + npc.display.skinOverlayData.overlayList.put(0,new SkinOverlayData( + assets.getAsset(slot.selected), true, 1.0F, 1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0F, 0.0F, 0.0F )); } diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java index 5189c34d5..902d4e46b 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java @@ -78,7 +78,7 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene y+=23; addLabel(new GuiNpcLabel(9,"display.overlay", guiLeft + 5, y + 5)); - addTextField(new GuiNpcTextField(9,this, fontRendererObj, guiLeft + 80, y, 200, 20, npc.display.skinOverlays.containsKey(0) ? npc.display.skinOverlays.get(0).getTexture() : "")); + addTextField(new GuiNpcTextField(9,this, fontRendererObj, guiLeft + 80, y, 200, 20, npc.display.skinOverlayData.overlayList.containsKey(0) ? npc.display.skinOverlayData.overlayList.get(0).getTexture() : "")); this.addButton(new GuiNpcButton(9, guiLeft + 283, y, 80, 20, "display.selectTexture")); y+=23; @@ -131,8 +131,8 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene else if(textfield.id == 9){ npc.textureGlowLocation = null; //display.glowTexture = textfield.getText(); - npc.display.skinOverlays.put(0,new SkinOverlayData( - textfield.getText(), true, 0.8F, 1.0F, 0.0F, 0.0F, + npc.display.skinOverlayData.overlayList.put(0,new SkinOverlayData( + textfield.getText(), true, 1.0F, 1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0F, 0.0F, 0.0F )); } diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java index 6af7252db..1938b7c3d 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java @@ -232,7 +232,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol } } //npc.display.glowTexture = ""; - npc.display.skinOverlays.remove(0); + npc.display.skinOverlayData.overlayList.remove(0); npc.textureLocation = null; npc.textureGlowLocation = null; npc.updateHitbox(); @@ -340,7 +340,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; } //npc.display.glowTexture = ""; - npc.display.skinOverlays.remove(0); + npc.display.skinOverlayData.overlayList.remove(0); npc.textureLocation = null; npc.textureGlowLocation = null; npc.updateHitbox(); diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java b/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java index c0eb3228f..b6b172986 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java @@ -130,7 +130,7 @@ public class GuiEntitySelection extends GuiNPCInterface npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; } //npc.display.glowTexture = ""; - npc.display.skinOverlays.remove(0); + npc.display.skinOverlayData.overlayList.remove(0); npc.textureLocation = null; npc.textureGlowLocation = null; npc.updateHitbox(); diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index a76edeb42..56292e0dd 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -213,13 +213,13 @@ public class RenderNPCInterface extends RenderLiving{ super.renderModel(entityliving, par2, par3, par4, par5, par6, par7); EntityNPCInterface npc = (EntityNPCInterface) entityliving; - if (!npc.display.skinOverlays.isEmpty()) { - for (ISkinOverlay overlayData : npc.display.skinOverlays.values()) { + if (!npc.display.skinOverlayData.overlayList.isEmpty()) { + for (ISkinOverlay overlayData : npc.display.skinOverlayData.overlayList.values()) { try { if (overlayData.getLocation() == null) { overlayData.setLocation(new ResourceLocation(overlayData.getTexture())); } else { - String str = npc.display.skinOverlays.get(0).getLocation().getResourceDomain()+":"+npc.display.skinOverlays.get(0).getLocation().getResourcePath(); + String str = npc.display.skinOverlayData.overlayList.get(0).getLocation().getResourceDomain()+":"+npc.display.skinOverlayData.overlayList.get(0).getLocation().getResourcePath(); if (!str.equals(overlayData.getTexture())) { overlayData.setLocation(new ResourceLocation(overlayData.getTexture())); } diff --git a/src/main/java/noppes/npcs/controllers/PlayerData.java b/src/main/java/noppes/npcs/controllers/PlayerData.java index 48588315e..ef1647ee7 100644 --- a/src/main/java/noppes/npcs/controllers/PlayerData.java +++ b/src/main/java/noppes/npcs/controllers/PlayerData.java @@ -11,6 +11,7 @@ import noppes.npcs.LogWriter; import noppes.npcs.constants.EnumRoleType; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.entity.data.DataSkinOverlays; import noppes.npcs.entity.data.DataTimers; import noppes.npcs.roles.RoleCompanion; import noppes.npcs.util.NBTJsonUtil; @@ -27,6 +28,7 @@ public class PlayerData implements IExtendedEntityProperties{ public PlayerItemGiverData itemgiverData = new PlayerItemGiverData(); public PlayerMailData mailData = new PlayerMailData(); public DataTimers timers = new DataTimers(this); + public DataSkinOverlays skinOverlays = new DataSkinOverlays(this); public EntityNPCInterface editingNpc; public NBTTagCompound cloned; @@ -64,6 +66,7 @@ public class PlayerData implements IExtendedEntityProperties{ itemgiverData.loadNBTData(data); mailData.loadNBTData(data); timers.readFromNBT(data); + skinOverlays.readFromNBT(data); if(player != null){ playername = player.getCommandSenderName(); @@ -100,6 +103,7 @@ public class PlayerData implements IExtendedEntityProperties{ itemgiverData.saveNBTData(compound); mailData.saveNBTData(compound); timers.writeToNBT(compound); + skinOverlays.writeToNBT(compound); compound.setString("PlayerName", playername); compound.setString("UUID", uuid); diff --git a/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java b/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java index 07466ce87..804f9f06b 100644 --- a/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java +++ b/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java @@ -1,9 +1,13 @@ package noppes.npcs.controllers.data; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; +import noppes.npcs.entity.data.DataSkinOverlays; import noppes.npcs.scripted.interfaces.ISkinOverlay; public class SkinOverlayData implements ISkinOverlay { + public DataSkinOverlays parent; public ResourceLocation location = null; public String texture; public boolean glow = true; @@ -20,6 +24,9 @@ public class SkinOverlayData implements ISkinOverlay { public float offsetY = 0.0F; public float offsetZ = 0.0F; + public SkinOverlayData() { + } + public SkinOverlayData(String texture) { this.texture = texture; } @@ -41,6 +48,7 @@ public class SkinOverlayData implements ISkinOverlay { public void setTexture(String texture) { this.texture = texture; + this.updateClient(); } public String getTexture() { return texture; @@ -48,6 +56,7 @@ public class SkinOverlayData implements ISkinOverlay { public void setGlow(boolean glow) { this.glow = glow; + this.updateClient(); } public boolean getGlow() { return glow; @@ -55,6 +64,7 @@ public class SkinOverlayData implements ISkinOverlay { public void setAlpha(float alpha) { this.alpha = alpha; + this.updateClient(); } public float getAlpha() { return alpha; @@ -62,6 +72,7 @@ public class SkinOverlayData implements ISkinOverlay { public void setSize(float size) { this.size = size; + this.updateClient(); } public float getSize() { return size; @@ -70,6 +81,7 @@ public class SkinOverlayData implements ISkinOverlay { public void setScale(float scaleX, float scaleY) { this.scaleX = scaleX; this.scaleY = scaleY; + this.updateClient(); } public float getScaleX() { return scaleX; @@ -81,6 +93,7 @@ public class SkinOverlayData implements ISkinOverlay { public void setSpeed(float speedX, float speedY) { this.speedX = speedX; this.speedY = speedY; + this.updateClient(); } public float getSpeedX() { return speedX; @@ -93,6 +106,7 @@ public class SkinOverlayData implements ISkinOverlay { this.offsetX = offsetX; this.offsetY = offsetY; this.offsetZ = offsetZ; + this.updateClient(); } public float getOffsetX() { return offsetX; @@ -106,8 +120,51 @@ public class SkinOverlayData implements ISkinOverlay { public void setLocation(ResourceLocation location) { this.location = location; + this.updateClient(); } public ResourceLocation getLocation() { return this.location; } + + public void readFromNBT(NBTTagCompound compound) { + this.texture = compound.getString("SkinOverlayTexture"); + this.glow = compound.getBoolean("SkinOverlayGlow"); + this.alpha = compound.getFloat("SkinOverlayAlpha"); + this.size = compound.getFloat("SkinOverlaySize"); + this.speedX = compound.getFloat("SkinOverlaySpeedX"); + this.speedY = compound.getFloat("SkinOverlaySpeedY"); + this.scaleX = compound.getFloat("SkinOverlayScaleX"); + this.scaleY = compound.getFloat("SkinOverlayScaleY"); + this.offsetX = compound.getFloat("SkinOverlayOffsetX"); + this.offsetY = compound.getFloat("SkinOverlayOffsetY"); + this.offsetZ = compound.getFloat("SkinOverlayOffsetZ"); + } + + public NBTTagCompound writeToNBT(NBTTagCompound compound) { + compound.setString("SkinOverlayTexture", this.getTexture()); + compound.setBoolean("SkinOverlayGlow", this.getGlow()); + compound.setFloat("SkinOverlayAlpha", this.getAlpha()); + compound.setFloat("SkinOverlaySize", this.getSize()); + compound.setFloat("SkinOverlaySpeedX", this.getSpeedX()); + compound.setFloat("SkinOverlaySpeedY", this.getSpeedY()); + compound.setFloat("SkinOverlayScaleX", this.getScaleX()); + compound.setFloat("SkinOverlayScaleY", this.getScaleY()); + compound.setFloat("SkinOverlayOffsetX", this.getOffsetX()); + compound.setFloat("SkinOverlayOffsetY", this.getOffsetY()); + compound.setFloat("SkinOverlayOffsetZ", this.getOffsetZ()); + + return compound; + } + + public static ISkinOverlay overlayFromNBT(NBTTagCompound compound) { + SkinOverlayData overlay = new SkinOverlayData(); + overlay.readFromNBT(compound); + return overlay; + } + + private void updateClient() { + if (this.parent != null) { + this.parent.updateClient(); + } + } } diff --git a/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java b/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java new file mode 100644 index 000000000..184260727 --- /dev/null +++ b/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java @@ -0,0 +1,82 @@ +package noppes.npcs.entity.data; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import noppes.npcs.controllers.PlayerData; +import noppes.npcs.controllers.data.SkinOverlayData; +import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.scripted.interfaces.ISkinOverlay; +import noppes.npcs.scripted.interfaces.handler.IOverlayHandler; +import java.util.HashMap; +import java.util.Map; + +public class DataSkinOverlays implements IOverlayHandler { + public final Object parent; + public HashMap overlayList = new HashMap<>(); + + public DataSkinOverlays(Object parent) { + this.parent = parent; + } + + public void readFromNBT(NBTTagCompound nbtTagCompound) { + HashMap skinOverlays = new HashMap<>(); + NBTTagList skinOverlayList = nbtTagCompound.getTagList("SkinOverlayData",10); + for (int i = 0; i < skinOverlayList.tagCount(); i++) { + int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID"); + SkinOverlayData skinOverlay = (SkinOverlayData) SkinOverlayData.overlayFromNBT(skinOverlayList.getCompoundTagAt(i)); + skinOverlays.put(tagID, skinOverlay); + } + + this.overlayList = skinOverlays; + } + + public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { + NBTTagList overlayList = new NBTTagList(); + if (!this.overlayList.isEmpty()) { + for (Map.Entry overlayData : this.overlayList.entrySet()) { + NBTTagCompound compound = new NBTTagCompound(); + compound.setInteger("SkinOverlayID", overlayData.getKey()); + compound = ((SkinOverlayData) overlayData.getValue()).writeToNBT(compound); + overlayList.appendTag(compound); + } + } + nbttagcompound.setTag("SkinOverlayData",overlayList); + return nbttagcompound; + } + + public void updateClient() { + if (parent instanceof PlayerData) { + NBTTagCompound compound = this.writeToNBT(new NBTTagCompound()); + ((PlayerData) parent).player.getEntityData().setTag("SkinOverlayData", compound.getTagList("SkinOverlayData",10)); + } else if (parent instanceof EntityNPCInterface) { + ((EntityNPCInterface) parent).updateClient = true; + } + } + + public void add(int id, ISkinOverlay data) { + ((SkinOverlayData) data).parent = this; + this.overlayList.put(id, data); + updateClient(); + } + + public ISkinOverlay get(int id) { + return this.overlayList.get(id); + } + + public boolean has(int id) { + return this.overlayList.containsKey(id); + } + + public boolean remove(int id) { + boolean removed = this.overlayList.remove(id) != null; + updateClient(); + return removed; + } + + public int size() { return this.overlayList.size(); } + + public void clear() { + this.overlayList.clear(); + updateClient(); + } +} diff --git a/src/main/java/noppes/npcs/entity/data/DataTimers.java b/src/main/java/noppes/npcs/entity/data/DataTimers.java index 6c0008c7e..a8da1fb29 100644 --- a/src/main/java/noppes/npcs/entity/data/DataTimers.java +++ b/src/main/java/noppes/npcs/entity/data/DataTimers.java @@ -18,7 +18,7 @@ import noppes.npcs.controllers.PlayerData; import noppes.npcs.scripted.CustomNPCsException; public class DataTimers implements ITimers { - private Object parent; + private final Object parent; private Map timers = new HashMap(); public DataTimers(Object parent) { diff --git a/src/main/java/noppes/npcs/entity/old/EntityNPCEnderman.java b/src/main/java/noppes/npcs/entity/old/EntityNPCEnderman.java index 6d983b834..5ce16e8a1 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNPCEnderman.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNPCEnderman.java @@ -20,8 +20,8 @@ public class EntityNPCEnderman extends EntityNpcEnderchibi super(world); display.texture = "customnpcs:textures/entity/enderman/enderman.png"; //display.glowTexture = ; - display.skinOverlays.put(0,new SkinOverlayData( - "customnpcs:textures/overlays/ender_eyes.png", true, 0.8F, 1.0F, 0.0F, 0.0F, + display.skinOverlayData.overlayList.put(0,new SkinOverlayData( + "customnpcs:textures/overlays/ender_eyes.png", true, 1.0F, 1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0F, 0.0F, 0.0F )); this.width = 0.6F; diff --git a/src/main/java/noppes/npcs/scripted/NpcAPI.java b/src/main/java/noppes/npcs/scripted/NpcAPI.java index 4b53ebf1c..1f5e0e216 100644 --- a/src/main/java/noppes/npcs/scripted/NpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/NpcAPI.java @@ -45,7 +45,6 @@ import noppes.npcs.scripted.interfaces.*; import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import noppes.npcs.scripted.interfaces.entity.IEntity; import noppes.npcs.scripted.interfaces.gui.ICustomGui; -import noppes.npcs.scripted.interfaces.item.IItemCustom; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.AbstractNpcAPI; import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index 6565a496f..68bf368ca 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -12,6 +12,7 @@ import noppes.npcs.scripted.ScriptFaction; import noppes.npcs.scripted.interfaces.ISkinOverlay; import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; import noppes.npcs.scripted.interfaces.entity.IPlayer; +import noppes.npcs.scripted.interfaces.handler.IOverlayHandler; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.constants.AnimationType; import noppes.npcs.scripted.constants.EntityType; @@ -1097,23 +1098,19 @@ public class ScriptNpc extends ScriptLiving imp } public void setOverlayTexture(String overlayTexture) { - this.setSkinOverlay(0, NpcAPI.Instance().createSkinOverlay(overlayTexture)); + this.getOverlays().add(0, NpcAPI.Instance().createSkinOverlay(overlayTexture)); + npc.updateClient = true; } + public String getOverlayTexture() { - if (!npc.display.skinOverlays.containsKey(0)) + if (!npc.display.skinOverlayData.overlayList.containsKey(0)) return ""; - return npc.display.skinOverlays.get(0).getTexture(); + return npc.display.skinOverlayData.overlayList.get(0).getTexture(); } - public void setSkinOverlay(int id, ISkinOverlay overlay) { - if (overlay != null) { - npc.display.skinOverlays.put(id, overlay); - } - } - - public void removeSkinOverlay(int id) { - npc.display.skinOverlays.remove(id); + public IOverlayHandler getOverlays() { + return npc.display.skinOverlayData; } public void setCollisionType(int type){ diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index 7a6c8d193..e199e966d 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -22,6 +22,7 @@ import noppes.npcs.scripted.*; import noppes.npcs.scripted.constants.EntityType; import noppes.npcs.scripted.gui.ScriptGui; import noppes.npcs.scripted.interfaces.entity.IEntity; +import noppes.npcs.scripted.interfaces.handler.IOverlayHandler; import noppes.npcs.scripted.interfaces.handler.data.IQuest; import noppes.npcs.scripted.interfaces.*; import noppes.npcs.scripted.interfaces.entity.IPlayer; @@ -32,12 +33,10 @@ import noppes.npcs.scripted.overlay.ScriptOverlay; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.util.ValueUtil; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Set; +import java.util.*; public class ScriptPlayer extends ScriptLivingBase implements IPlayer { + public HashMap skinOverlays = new HashMap<>(); public T player; private PlayerData data; @@ -527,58 +526,8 @@ public class ScriptPlayer extends ScriptLivingBase Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.OVERLAY_CLOSE, id, new NBTTagCompound()); } - public void setSkinOverlay(int id, ISkinOverlay overlay) { - if (id < 0) { - throw new CustomNPCsException("Skin overlay ID must be greater than 0."); - } - - if (overlay != null) { - NBTTagCompound data = new NBTTagCompound(); - NBTTagCompound compound = new NBTTagCompound(); - - compound.setInteger("SkinOverlayID", id); - compound.setString("SkinOverlayTexture", overlay.getTexture()); - compound.setBoolean("SkinOverlayGlow", overlay.getGlow()); - compound.setFloat("SkinOverlayAlpha", overlay.getAlpha()); - compound.setFloat("SkinOverlaySize", overlay.getSize()); - compound.setFloat("SkinOverlaySpeedX", overlay.getSpeedX()); - compound.setFloat("SkinOverlaySpeedY", overlay.getSpeedY()); - compound.setFloat("SkinOverlayScaleX", overlay.getScaleX()); - compound.setFloat("SkinOverlayScaleY", overlay.getScaleY()); - compound.setFloat("SkinOverlayOffsetX", overlay.getOffsetX()); - compound.setFloat("SkinOverlayOffsetY", overlay.getOffsetY()); - compound.setFloat("SkinOverlayOffsetZ", overlay.getOffsetZ()); - - if (!player.getEntityData().hasKey("SkinOverlayData")) { - NBTTagList tagList = new NBTTagList(); - tagList.appendTag(compound); - player.getEntityData().setTag("SkinOverlayData", tagList); - } else { - for (int i = 0; i < player.getEntityData().getTagList("SkinOverlayData", 10).tagCount(); i++) { - int tagID = player.getEntityData().getTagList("SkinOverlayData", 10).getCompoundTagAt(i).getInteger("SkinOverlayID"); - if (tagID == id) { - player.getEntityData().getTagList("SkinOverlayData", 10).removeTag(i); - } - } - player.getEntityData().getTagList("SkinOverlayData", 10).appendTag(compound); - } - data.setTag("SkinOverlayData",player.getEntityData().getTagList("SkinOverlayData",10)); - Server.sendData((EntityPlayerMP) this.entity, EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS, data); - } - } - - public void removeSkinOverlay(int id) { - if (player.getEntityData().hasKey("SkinOverlayData")) { - NBTTagCompound data = new NBTTagCompound(); - for (int i = 0; i < player.getEntityData().getTagList("SkinOverlayData",10).tagCount(); i++) { - int tagID = player.getEntityData().getTagList("SkinOverlayData",10).getCompoundTagAt(i).getInteger("SkinOverlayID"); - if (tagID == id) { - player.getEntityData().getTagList("SkinOverlayData",10).removeTag(i); - } - } - data.setTag("SkinOverlayData",player.getEntityData().getTagList("SkinOverlayData",10)); - Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS, data); - } + public IOverlayHandler getOverlays() { + return this.getData().skinOverlays; } public IQuest[] getFinishedQuests() { diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java index 43e3f1dc6..08a1e8c12 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/ICustomNpc.java @@ -8,6 +8,7 @@ package noppes.npcs.scripted.interfaces.entity; import net.minecraft.entity.EntityCreature; import noppes.npcs.scripted.ScriptFaction; import noppes.npcs.scripted.interfaces.ISkinOverlay; +import noppes.npcs.scripted.interfaces.handler.IOverlayHandler; import noppes.npcs.scripted.interfaces.item.IItemStack; import noppes.npcs.scripted.interfaces.ITimers; import noppes.npcs.scripted.roles.*; @@ -747,9 +748,7 @@ public interface ICustomNpc extends IEntityLiving { String getOverlayTexture(); - void setSkinOverlay(int id, ISkinOverlay overlay); - - void removeSkinOverlay(int id); + IOverlayHandler getOverlays(); void setCollisionType(int type); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java index d45165fd1..156da123d 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IPlayer.java @@ -4,6 +4,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayerMP; import noppes.npcs.scripted.ScriptBlock; import noppes.npcs.scripted.entity.ScriptDBCPlayer; +import noppes.npcs.scripted.interfaces.handler.IOverlayHandler; import noppes.npcs.scripted.interfaces.handler.data.IQuest; import noppes.npcs.scripted.interfaces.*; import noppes.npcs.scripted.interfaces.gui.ICustomGui; @@ -225,9 +226,7 @@ public interface IPlayer extends IEntityLivingBase void closeOverlay(int id); - void setSkinOverlay(int id, ISkinOverlay overlay); - - void removeSkinOverlay(int id); + IOverlayHandler getOverlays(); IQuest[] getFinishedQuests(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/handler/IOverlayHandler.java b/src/main/java/noppes/npcs/scripted/interfaces/handler/IOverlayHandler.java new file mode 100644 index 000000000..b9cfd1494 --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/interfaces/handler/IOverlayHandler.java @@ -0,0 +1,18 @@ +package noppes.npcs.scripted.interfaces.handler; + +import noppes.npcs.scripted.interfaces.ISkinOverlay; + +public interface IOverlayHandler { + + void add(int id, ISkinOverlay overlay); + + ISkinOverlay get(int id); + + boolean has(int id); + + boolean remove(int id); + + int size(); + + void clear(); +} From b6c62332edbb39728acd54e7c98da7531bc3ff6b Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Mon, 23 May 2022 20:47:32 -0500 Subject: [PATCH 66/75] Fixed SkinOverlay objects not having their parent object initialized correctly. --- src/main/java/noppes/npcs/DataDisplay.java | 5 ++--- src/main/java/noppes/npcs/client/Client.java | 4 ++-- src/main/java/noppes/npcs/client/NoppesUtil.java | 6 +++--- .../npcs/client/gui/GuiNpcTextureOverlays.java | 4 ++-- .../npcs/client/gui/mainmenu/GuiNpcDisplay.java | 4 ++-- .../npcs/client/gui/model/GuiCreationScreen.java | 3 --- .../npcs/client/gui/model/GuiEntitySelection.java | 3 --- .../npcs/client/renderer/RenderCNPCPlayer.java | 6 +++--- .../npcs/client/renderer/RenderNPCInterface.java | 1 - .../data/{SkinOverlayData.java => SkinOverlay.java} | 13 ++++++------- .../noppes/npcs/entity/data/DataSkinOverlays.java | 9 +++++---- .../noppes/npcs/entity/old/EntityNPCEnderman.java | 5 ++--- src/main/java/noppes/npcs/scripted/NpcAPI.java | 4 ++-- .../java/noppes/npcs/scripted/entity/ScriptNpc.java | 2 -- 14 files changed, 29 insertions(+), 40 deletions(-) rename src/main/java/noppes/npcs/controllers/data/{SkinOverlayData.java => SkinOverlay.java} (91%) diff --git a/src/main/java/noppes/npcs/DataDisplay.java b/src/main/java/noppes/npcs/DataDisplay.java index 70f4fbda5..15dbe469a 100644 --- a/src/main/java/noppes/npcs/DataDisplay.java +++ b/src/main/java/noppes/npcs/DataDisplay.java @@ -8,10 +8,9 @@ import net.minecraft.nbt.NBTTagString; import net.minecraft.nbt.NBTUtil; import net.minecraft.server.MinecraftServer; import net.minecraft.util.StringUtils; -import noppes.npcs.controllers.data.SkinOverlayData; +import noppes.npcs.controllers.data.SkinOverlay; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.data.DataSkinOverlays; -import noppes.npcs.scripted.interfaces.ISkinOverlay; import noppes.npcs.util.ValueUtil; import com.google.common.collect.Iterables; @@ -140,7 +139,7 @@ public class DataDisplay { if (!nbttagcompound.hasKey("SkinOverlayData") && !glowTexture.isEmpty()) { NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("SkinOverlayID", 0); //unique glow texture ID - (new SkinOverlayData(glowTexture)).writeToNBT(nbttagcompound); + (new SkinOverlay(glowTexture)).writeToNBT(nbttagcompound); if (!nbttagcompound.hasKey("SkinOverlayData")) { NBTTagList tagList = new NBTTagList(); diff --git a/src/main/java/noppes/npcs/client/Client.java b/src/main/java/noppes/npcs/client/Client.java index 94343800a..248885aa7 100644 --- a/src/main/java/noppes/npcs/client/Client.java +++ b/src/main/java/noppes/npcs/client/Client.java @@ -12,12 +12,12 @@ import noppes.npcs.Server; import noppes.npcs.client.gui.customoverlay.OverlayCustom; import noppes.npcs.constants.EnumPacketServer; import cpw.mods.fml.common.network.internal.FMLProxyPacket; -import noppes.npcs.controllers.data.SkinOverlayData; +import noppes.npcs.controllers.data.SkinOverlay; public class Client { public static HashMap customOverlays = new HashMap<>(); - public static HashMap> skinOverlays = new HashMap<>(); + public static HashMap> skinOverlays = new HashMap<>(); public static HashMap entitySkinOverlayTicks = new HashMap<>(); public static void sendData(EnumPacketServer enu, Object... obs) { diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index b59d27fe9..52e92a78c 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -36,7 +36,7 @@ import noppes.npcs.constants.EnumPlayerPacket; import noppes.npcs.controllers.Dialog; import noppes.npcs.controllers.DialogController; import noppes.npcs.controllers.Quest; -import noppes.npcs.controllers.data.SkinOverlayData; +import noppes.npcs.controllers.data.SkinOverlay; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.Sys; @@ -73,12 +73,12 @@ public class NoppesUtil { } public static void updateSkinOverlayData(EntityPlayer player, NBTTagCompound compound) { - HashMap skinOverlays = new HashMap<>(); + HashMap skinOverlays = new HashMap<>(); NBTTagList skinOverlayList = compound.getTagList("SkinOverlayData",10); for (int i = 0; i < skinOverlayList.tagCount(); i++) { int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID"); - skinOverlays.put(tagID, (SkinOverlayData) SkinOverlayData.overlayFromNBT(skinOverlayList.getCompoundTagAt(i))); + skinOverlays.put(tagID, (SkinOverlay) SkinOverlay.overlayFromNBT(skinOverlayList.getCompoundTagAt(i))); } Client.skinOverlays.put(player.getUniqueID(), skinOverlays); } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java b/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java index 7a1d7dd0d..4a67adc62 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcTextureOverlays.java @@ -4,7 +4,7 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderManager; -import noppes.npcs.controllers.data.SkinOverlayData; +import noppes.npcs.controllers.data.SkinOverlay; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.opengl.GL11; @@ -79,7 +79,7 @@ public class GuiNpcTextureOverlays extends GuiNpcSelectionInterface{ //npc.display.glowTexture = assets.getAsset(slot.selected); npc.textureGlowLocation = null; - npc.display.skinOverlayData.overlayList.put(0,new SkinOverlayData( + npc.display.skinOverlayData.overlayList.put(0,new SkinOverlay( assets.getAsset(slot.selected), true, 1.0F, 1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0F, 0.0F, 0.0F )); diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java index 902d4e46b..f6423f312 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java @@ -15,7 +15,7 @@ import noppes.npcs.client.gui.SubGuiNpcName; import noppes.npcs.client.gui.model.GuiCreationScreen; import noppes.npcs.client.gui.util.*; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.data.SkinOverlayData; +import noppes.npcs.controllers.data.SkinOverlay; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; @@ -131,7 +131,7 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene else if(textfield.id == 9){ npc.textureGlowLocation = null; //display.glowTexture = textfield.getText(); - npc.display.skinOverlayData.overlayList.put(0,new SkinOverlayData( + npc.display.skinOverlayData.overlayList.put(0,new SkinOverlay( textfield.getText(), true, 1.0F, 1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0F, 0.0F, 0.0F )); diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java index 1938b7c3d..82c5a76ef 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java @@ -21,7 +21,6 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagByte; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import noppes.npcs.client.Client; import noppes.npcs.client.gui.util.GuiCustomScroll; @@ -31,11 +30,9 @@ import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.ICustomScrollListener; import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.controllers.PixelmonHelper; -import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityFakeLiving; import noppes.npcs.entity.EntityNPCInterface; -import org.lwjgl.Sys; public class GuiCreationScreen extends GuiModelInterface implements ICustomScrollListener{ diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java b/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java index b6b172986..15704114e 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiEntitySelection.java @@ -3,7 +3,6 @@ package noppes.npcs.client.gui.model; import java.util.Collections; import java.util.Vector; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; @@ -12,13 +11,11 @@ import net.minecraft.client.renderer.entity.NPCRendererHelper; import net.minecraft.client.renderer.entity.RendererLivingEntity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.ResourceLocation; import noppes.npcs.ModelData; import noppes.npcs.client.EntityUtil; import noppes.npcs.client.gui.util.GuiNPCInterface; import noppes.npcs.client.gui.util.GuiNPCStringSlot; import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.entity.EntityCustomNpc; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index 23122927e..4756215fc 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -21,7 +21,7 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import noppes.npcs.client.Client; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.data.SkinOverlayData; +import noppes.npcs.controllers.data.SkinOverlay; import org.lwjgl.opengl.GL11; import org.lwjgl.util.glu.Project; @@ -112,7 +112,7 @@ public class RenderCNPCPlayer extends RenderPlayer { if (!p_77036_1_.isInvisible()) { if (Client.skinOverlays.containsKey(player.getUniqueID())) { - for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { + for (SkinOverlay overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { if (overlayData.location == null) { overlayData.location = new ResourceLocation(overlayData.texture); } else { @@ -312,7 +312,7 @@ public class RenderCNPCPlayer extends RenderPlayer { renderplayer.renderFirstPersonArm(player); if (Client.skinOverlays.containsKey(player.getUniqueID())) { - for (SkinOverlayData overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { + for (SkinOverlay overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) { if (overlayData.location == null) { overlayData.location = new ResourceLocation(overlayData.texture); } else { diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index 56292e0dd..b99f6f839 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -23,7 +23,6 @@ import noppes.npcs.client.ImageDownloadAlt; import noppes.npcs.client.model.ModelMPM; import noppes.npcs.constants.EnumAnimation; import noppes.npcs.constants.EnumStandingType; -import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; diff --git a/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java b/src/main/java/noppes/npcs/controllers/data/SkinOverlay.java similarity index 91% rename from src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java rename to src/main/java/noppes/npcs/controllers/data/SkinOverlay.java index 804f9f06b..750a76469 100644 --- a/src/main/java/noppes/npcs/controllers/data/SkinOverlayData.java +++ b/src/main/java/noppes/npcs/controllers/data/SkinOverlay.java @@ -1,12 +1,11 @@ package noppes.npcs.controllers.data; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import noppes.npcs.entity.data.DataSkinOverlays; import noppes.npcs.scripted.interfaces.ISkinOverlay; -public class SkinOverlayData implements ISkinOverlay { +public class SkinOverlay implements ISkinOverlay { public DataSkinOverlays parent; public ResourceLocation location = null; public String texture; @@ -24,15 +23,15 @@ public class SkinOverlayData implements ISkinOverlay { public float offsetY = 0.0F; public float offsetZ = 0.0F; - public SkinOverlayData() { + public SkinOverlay() { } - public SkinOverlayData(String texture) { + public SkinOverlay(String texture) { this.texture = texture; } - public SkinOverlayData(String texture, boolean glow, float alpha, float size, float speedX, float speedY, - float scaleX, float scaleY, float offsetX, float offsetY, float offsetZ) { + public SkinOverlay(String texture, boolean glow, float alpha, float size, float speedX, float speedY, + float scaleX, float scaleY, float offsetX, float offsetY, float offsetZ) { this.texture = texture; this.glow = glow; this.alpha = alpha; @@ -157,7 +156,7 @@ public class SkinOverlayData implements ISkinOverlay { } public static ISkinOverlay overlayFromNBT(NBTTagCompound compound) { - SkinOverlayData overlay = new SkinOverlayData(); + SkinOverlay overlay = new SkinOverlay(); overlay.readFromNBT(compound); return overlay; } diff --git a/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java b/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java index 184260727..9a9e297ea 100644 --- a/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java +++ b/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java @@ -3,7 +3,7 @@ package noppes.npcs.entity.data; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.controllers.PlayerData; -import noppes.npcs.controllers.data.SkinOverlayData; +import noppes.npcs.controllers.data.SkinOverlay; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.interfaces.ISkinOverlay; import noppes.npcs.scripted.interfaces.handler.IOverlayHandler; @@ -23,7 +23,8 @@ public class DataSkinOverlays implements IOverlayHandler { NBTTagList skinOverlayList = nbtTagCompound.getTagList("SkinOverlayData",10); for (int i = 0; i < skinOverlayList.tagCount(); i++) { int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID"); - SkinOverlayData skinOverlay = (SkinOverlayData) SkinOverlayData.overlayFromNBT(skinOverlayList.getCompoundTagAt(i)); + SkinOverlay skinOverlay = (SkinOverlay) SkinOverlay.overlayFromNBT(skinOverlayList.getCompoundTagAt(i)); + skinOverlay.parent = this; skinOverlays.put(tagID, skinOverlay); } @@ -36,7 +37,7 @@ public class DataSkinOverlays implements IOverlayHandler { for (Map.Entry overlayData : this.overlayList.entrySet()) { NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("SkinOverlayID", overlayData.getKey()); - compound = ((SkinOverlayData) overlayData.getValue()).writeToNBT(compound); + compound = ((SkinOverlay) overlayData.getValue()).writeToNBT(compound); overlayList.appendTag(compound); } } @@ -54,7 +55,7 @@ public class DataSkinOverlays implements IOverlayHandler { } public void add(int id, ISkinOverlay data) { - ((SkinOverlayData) data).parent = this; + ((SkinOverlay) data).parent = this; this.overlayList.put(id, data); updateClient(); } diff --git a/src/main/java/noppes/npcs/entity/old/EntityNPCEnderman.java b/src/main/java/noppes/npcs/entity/old/EntityNPCEnderman.java index 5ce16e8a1..62c4c224c 100644 --- a/src/main/java/noppes/npcs/entity/old/EntityNPCEnderman.java +++ b/src/main/java/noppes/npcs/entity/old/EntityNPCEnderman.java @@ -6,11 +6,10 @@ package noppes.npcs.entity.old; import net.minecraft.entity.monster.EntityEnderman; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import noppes.npcs.ModelData; import noppes.npcs.constants.EnumAnimation; -import noppes.npcs.controllers.data.SkinOverlayData; +import noppes.npcs.controllers.data.SkinOverlay; import noppes.npcs.entity.EntityCustomNpc; public class EntityNPCEnderman extends EntityNpcEnderchibi @@ -20,7 +19,7 @@ public class EntityNPCEnderman extends EntityNpcEnderchibi super(world); display.texture = "customnpcs:textures/entity/enderman/enderman.png"; //display.glowTexture = ; - display.skinOverlayData.overlayList.put(0,new SkinOverlayData( + display.skinOverlayData.overlayList.put(0,new SkinOverlay( "customnpcs:textures/overlays/ender_eyes.png", true, 1.0F, 1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0F, 0.0F, 0.0F )); diff --git a/src/main/java/noppes/npcs/scripted/NpcAPI.java b/src/main/java/noppes/npcs/scripted/NpcAPI.java index 1f5e0e216..877dd19a0 100644 --- a/src/main/java/noppes/npcs/scripted/NpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/NpcAPI.java @@ -32,7 +32,7 @@ import net.minecraft.world.WorldServer; import noppes.npcs.CustomNpcs; import noppes.npcs.NoppesUtilServer; import noppes.npcs.controllers.*; -import noppes.npcs.controllers.data.SkinOverlayData; +import noppes.npcs.controllers.data.SkinOverlay; import noppes.npcs.items.ItemScripted; import noppes.npcs.containers.ContainerNpcInterface; import noppes.npcs.entity.EntityCustomNpc; @@ -355,6 +355,6 @@ public class NpcAPI extends AbstractNpcAPI { } public ISkinOverlay createSkinOverlay(String texture) { - return new SkinOverlayData(texture); + return new SkinOverlay(texture); } } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index 68bf368ca..a2c4a846b 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -5,11 +5,9 @@ import noppes.npcs.CustomNpcs; import noppes.npcs.NoppesUtilServer; import noppes.npcs.constants.*; import noppes.npcs.controllers.Line; -import noppes.npcs.controllers.data.SkinOverlayData; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.ScriptFaction; -import noppes.npcs.scripted.interfaces.ISkinOverlay; import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase; import noppes.npcs.scripted.interfaces.entity.IPlayer; import noppes.npcs.scripted.interfaces.handler.IOverlayHandler; From 82938fe5cd3dc432c215520fcbd647208cb44ab5 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 24 May 2022 00:11:34 -0500 Subject: [PATCH 67/75] Fixed NBT issue with player overlays. --- src/main/java/noppes/npcs/PacketHandlerServer.java | 2 +- .../java/noppes/npcs/ScriptPlayerEventHandler.java | 10 ---------- .../java/noppes/npcs/client/PacketHandlerClient.java | 4 +++- .../java/noppes/npcs/entity/data/DataSkinOverlays.java | 3 +++ 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/main/java/noppes/npcs/PacketHandlerServer.java b/src/main/java/noppes/npcs/PacketHandlerServer.java index aa478c0ed..4c593221d 100644 --- a/src/main/java/noppes/npcs/PacketHandlerServer.java +++ b/src/main/java/noppes/npcs/PacketHandlerServer.java @@ -148,7 +148,7 @@ public class PacketHandlerServer{ public void updateSkinOverlays(EntityPlayerMP player) { NBTTagCompound data = new NBTTagCompound(); data.setTag("SkinOverlayData",player.getEntityData().getTagList("SkinOverlayData",10)); - Server.sendData(player, EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS, data); + Server.sendToAll(EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS, player.getEntityId(), data); } private void getScriptsEnabled(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException { diff --git a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java index cf8a930c7..0af567230 100644 --- a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java @@ -432,16 +432,6 @@ public class ScriptPlayerEventHandler { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerLogin(handler, scriptPlayer); - - //Loads other players' and own player's skin overlays if they have them - /* - List list = MinecraftServer.getServer().getConfigurationManager().playerEntityList; - for (EntityPlayerMP playerMP : list) { - if (playerMP.getEntityData().hasKey("SkinOverlayData")) { - NBTTagCompound data = new NBTTagCompound(); - data.setTag("SkinOverlayData",playerMP.getEntityData().getTagList("SkinOverlayData",10)); - } - }*/ } } diff --git a/src/main/java/noppes/npcs/client/PacketHandlerClient.java b/src/main/java/noppes/npcs/client/PacketHandlerClient.java index f7baf4fba..607abd189 100644 --- a/src/main/java/noppes/npcs/client/PacketHandlerClient.java +++ b/src/main/java/noppes/npcs/client/PacketHandlerClient.java @@ -274,7 +274,9 @@ public class PacketHandlerClient extends PacketHandlerServer{ Minecraft.getMinecraft().thePlayer.swingItem(); } else if(type == EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS) { - NoppesUtil.updateSkinOverlayData(player, Server.readNBT(buffer)); + EntityPlayer sendingPlayer = (EntityPlayer) Minecraft.getMinecraft().theWorld.getEntityByID(buffer.readInt()); + NBTTagCompound compound = Server.readNBT(buffer); + NoppesUtil.updateSkinOverlayData(sendingPlayer, compound); } } } diff --git a/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java b/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java index 9a9e297ea..165aff11e 100644 --- a/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java +++ b/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java @@ -2,6 +2,8 @@ package noppes.npcs.entity.data; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import noppes.npcs.Server; +import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.controllers.PlayerData; import noppes.npcs.controllers.data.SkinOverlay; import noppes.npcs.entity.EntityNPCInterface; @@ -49,6 +51,7 @@ public class DataSkinOverlays implements IOverlayHandler { if (parent instanceof PlayerData) { NBTTagCompound compound = this.writeToNBT(new NBTTagCompound()); ((PlayerData) parent).player.getEntityData().setTag("SkinOverlayData", compound.getTagList("SkinOverlayData",10)); + Server.sendToAll(EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS, ((PlayerData) parent).player.getEntityId(), compound); } else if (parent instanceof EntityNPCInterface) { ((EntityNPCInterface) parent).updateClient = true; } From 532180f00feaf2f9bed99df52114667f7404d9c0 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 24 May 2022 00:36:47 -0500 Subject: [PATCH 68/75] Fixed NBT issue with player overlays. --- src/main/java/noppes/npcs/PacketHandlerServer.java | 4 +--- src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/noppes/npcs/PacketHandlerServer.java b/src/main/java/noppes/npcs/PacketHandlerServer.java index 4c593221d..c764e97ea 100644 --- a/src/main/java/noppes/npcs/PacketHandlerServer.java +++ b/src/main/java/noppes/npcs/PacketHandlerServer.java @@ -146,9 +146,7 @@ public class PacketHandlerServer{ } public void updateSkinOverlays(EntityPlayerMP player) { - NBTTagCompound data = new NBTTagCompound(); - data.setTag("SkinOverlayData",player.getEntityData().getTagList("SkinOverlayData",10)); - Server.sendToAll(EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS, player.getEntityId(), data); + PlayerDataController.instance.getPlayerData(player).skinOverlays.updateClient(); } private void getScriptsEnabled(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException { diff --git a/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java b/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java index 165aff11e..819159c9f 100644 --- a/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java +++ b/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java @@ -29,8 +29,8 @@ public class DataSkinOverlays implements IOverlayHandler { skinOverlay.parent = this; skinOverlays.put(tagID, skinOverlay); } - this.overlayList = skinOverlays; + this.updateClient(); } public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { From 991635f4cce4afb2fe94bddfb1e87b6a674cb0d6 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 24 May 2022 00:48:33 -0500 Subject: [PATCH 69/75] Sped up how fast hotbar items are switched when players have a skin overlay on. --- .../{OverlayRenderHelper.java => RenderCNPCHand.java} | 6 +++--- .../java/noppes/npcs/client/renderer/RenderCNPCPlayer.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/main/java/noppes/npcs/client/renderer/{OverlayRenderHelper.java => RenderCNPCHand.java} (99%) diff --git a/src/main/java/noppes/npcs/client/renderer/OverlayRenderHelper.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCHand.java similarity index 99% rename from src/main/java/noppes/npcs/client/renderer/OverlayRenderHelper.java rename to src/main/java/noppes/npcs/client/renderer/RenderCNPCHand.java index f8394b610..8b1bf617d 100644 --- a/src/main/java/noppes/npcs/client/renderer/OverlayRenderHelper.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCHand.java @@ -24,7 +24,7 @@ import org.lwjgl.opengl.GL12; import static net.minecraftforge.client.IItemRenderer.ItemRenderType.*; -public class OverlayRenderHelper extends ItemRenderer { +public class RenderCNPCHand extends ItemRenderer { private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); private static final ResourceLocation RES_MAP_BACKGROUND = new ResourceLocation("textures/map/map_background.png"); private static final ResourceLocation RES_UNDERWATER_OVERLAY = new ResourceLocation("textures/misc/underwater.png"); @@ -39,7 +39,7 @@ public class OverlayRenderHelper extends ItemRenderer { /** The index of the currently held item (0-8, or -1 if not yet updated) */ private int equippedItemSlot = -1; - public OverlayRenderHelper(Minecraft mc) { + public RenderCNPCHand(Minecraft mc) { super(mc); this.mc = mc; } @@ -572,7 +572,7 @@ public class OverlayRenderHelper extends ItemRenderer { f2 = f; } - this.equippedProgress += f2/4.0F; + this.equippedProgress += f2/2.0F; if (this.equippedProgress < 0.1F) { diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index 4756215fc..111281263 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -29,7 +29,7 @@ import java.lang.reflect.InvocationTargetException; import java.util.HashMap; public class RenderCNPCPlayer extends RenderPlayer { - public OverlayRenderHelper itemRenderer = new OverlayRenderHelper(Minecraft.getMinecraft()); + public RenderCNPCHand itemRenderer = new RenderCNPCHand(Minecraft.getMinecraft()); public float tempRenderPartialTicks; private float debugCamFOV; private float prevDebugCamFOV; From d040fa3da7ce5876dc8ecbddf71d077298669c4d Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 24 May 2022 00:58:12 -0500 Subject: [PATCH 70/75] Overlays blend with alpha values whether glowing or not. --- .../noppes/npcs/client/renderer/RenderCNPCPlayer.java | 9 ++++----- .../noppes/npcs/client/renderer/RenderNPCInterface.java | 8 +++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index 111281263..ac1a762f6 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -63,12 +63,12 @@ public class RenderCNPCPlayer extends RenderPlayer { float partialTickTime = Client.entitySkinOverlayTicks.get(player.getUniqueID()); // Overlay & Glow + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); + if (glow) { - GL11.glDepthFunc(GL11.GL_LEQUAL); - GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LIGHTING); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); Minecraft.getMinecraft().entityRenderer.disableLightmap((double)0); RenderHelper.disableStandardItemLighting(); } @@ -98,7 +98,6 @@ public class RenderCNPCPlayer extends RenderPlayer { GL11.glEnable(GL11.GL_LIGHTING); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDisable(GL11.GL_BLEND); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); Minecraft.getMinecraft().entityRenderer.enableLightmap((double) 0); diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index b99f6f839..08760d018 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -227,11 +227,12 @@ public class RenderNPCInterface extends RenderLiving{ this.bindTexture(overlayData.getLocation()); // Overlay & Glow + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); + if (overlayData.getGlow()) { - GL11.glDepthFunc(GL11.GL_LEQUAL); - GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LIGHTING); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); Minecraft.getMinecraft().entityRenderer.disableLightmap((double) 0); } @@ -266,6 +267,7 @@ public class RenderNPCInterface extends RenderLiving{ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glDisable(GL11.GL_BLEND); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); Minecraft.getMinecraft().entityRenderer.enableLightmap((double) 0); } catch (Exception ignored) { } From 33bb0307e91eaf5babb6e13d813a83b0548f8716 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 24 May 2022 01:07:50 -0500 Subject: [PATCH 71/75] Separated data objects and data controller objects in the noppes.npcs.controllers package. --- src/main/java/foxz/command/CmdDialog.java | 7 ++-- src/main/java/foxz/command/CmdFaction.java | 6 ++-- src/main/java/foxz/command/CmdNoppes.java | 2 +- src/main/java/foxz/command/CmdQuest.java | 11 ++---- .../commandhelper/AbstractCommandHelper.java | 2 +- src/main/java/noppes/npcs/CommonProxy.java | 3 +- src/main/java/noppes/npcs/DataAdvanced.java | 8 ++--- src/main/java/noppes/npcs/EventHooks.java | 3 +- src/main/java/noppes/npcs/NPCSpawning.java | 2 +- .../java/noppes/npcs/NoppesUtilPlayer.java | 1 + .../java/noppes/npcs/NoppesUtilServer.java | 34 +++++++++---------- .../java/noppes/npcs/PacketHandlerPlayer.java | 3 +- .../java/noppes/npcs/PacketHandlerServer.java | 4 +-- src/main/java/noppes/npcs/QuestLogData.java | 4 +-- .../noppes/npcs/ScriptPlayerEventHandler.java | 8 ++--- .../java/noppes/npcs/ServerEventsHandler.java | 2 +- .../noppes/npcs/VersionCompatibility.java | 4 +-- .../java/noppes/npcs/ai/EntityAIWander.java | 2 +- .../noppes/npcs/blocks/tiles/TileBorder.java | 2 +- .../npcs/blocks/tiles/TileRedstoneBlock.java | 2 +- .../npcs/blocks/tiles/TileWaypoint.java | 6 ++-- .../java/noppes/npcs/client/ClientProxy.java | 2 +- .../java/noppes/npcs/client/NoppesUtil.java | 4 +-- .../npcs/client/PacketHandlerClient.java | 2 +- .../npcs/client/gui/GuiNPCLinesEdit.java | 4 +-- .../client/gui/SubGuiMailmanSendSetup.java | 2 +- .../client/gui/SubGuiNpcAvailability.java | 4 +-- .../gui/SubGuiNpcAvailabilityDialog.java | 5 ++- .../gui/SubGuiNpcAvailabilityQuest.java | 5 ++- .../npcs/client/gui/SubGuiNpcBiomes.java | 10 +----- .../npcs/client/gui/SubGuiNpcDialogExtra.java | 11 ++---- .../client/gui/SubGuiNpcDialogOption.java | 4 +-- .../client/gui/SubGuiNpcDialogOptions.java | 4 +-- .../client/gui/SubGuiNpcFactionOptions.java | 2 +- .../client/gui/SubGuiNpcFactionPoints.java | 2 +- .../gui/advanced/GuiNPCAdvancedLinkedNpc.java | 17 ---------- .../gui/advanced/GuiNPCDialogNpcOptions.java | 2 +- .../client/gui/advanced/GuiNPCNightSetup.java | 2 +- .../client/gui/global/GuiNPCManageBanks.java | 2 +- .../gui/global/GuiNPCManageDialogs.java | 8 ++--- .../gui/global/GuiNPCManageFactions.java | 2 +- .../gui/global/GuiNPCManageLinkedNpc.java | 15 -------- .../client/gui/global/GuiNPCManageQuest.java | 6 ++-- .../gui/global/GuiNpcManageRecipes.java | 2 +- .../gui/global/GuiNpcNaturalSpawns.java | 2 +- .../client/gui/global/GuiNpcQuestReward.java | 2 +- .../gui/global/SubGuiNpcQuestAdvanced.java | 7 ++-- .../client/gui/player/GuiDialogInteract.java | 4 +-- .../npcs/client/gui/player/GuiFaction.java | 4 +-- .../npcs/client/gui/player/GuiMailbox.java | 4 +-- .../client/gui/player/GuiMailmanWrite.java | 2 +- .../client/gui/player/GuiQuestCompletion.java | 3 +- .../npcs/client/gui/player/GuiRecipes.java | 3 +- .../gui/questtypes/GuiNpcQuestTypeDialog.java | 3 +- .../gui/questtypes/GuiNpcQuestTypeItem.java | 2 +- .../gui/questtypes/GuiNpcQuestTypeKill.java | 2 +- .../questtypes/GuiNpcQuestTypeLocation.java | 3 +- .../client/gui/roles/GuiNpcBankSetup.java | 2 +- .../client/gui/roles/GuiNpcTransporter.java | 6 +--- .../containers/ContainerCarpentryBench.java | 2 +- .../noppes/npcs/containers/ContainerMail.java | 11 ++---- .../npcs/containers/ContainerManageBanks.java | 2 +- .../containers/ContainerManageRecipes.java | 2 +- .../containers/ContainerNPCBankInterface.java | 3 +- .../containers/ContainerNpcQuestReward.java | 2 +- .../containers/ContainerNpcQuestTypeItem.java | 2 +- .../npcs/controllers/BankController.java | 6 +--- .../npcs/controllers/DialogController.java | 3 ++ .../npcs/controllers/FactionController.java | 1 + .../controllers/PlayerDataController.java | 7 ++-- .../controllers/PlayerQuestController.java | 6 +++- .../npcs/controllers/QuestController.java | 2 ++ .../npcs/controllers/RecipeController.java | 4 ++- .../npcs/controllers/SpawnController.java | 1 + .../npcs/controllers/TransportController.java | 5 ++- .../controllers/{ => data}/Availability.java | 5 ++- .../npcs/controllers/{ => data}/Bank.java | 2 +- .../npcs/controllers/{ => data}/BankData.java | 3 +- .../npcs/controllers/{ => data}/Dialog.java | 4 ++- .../{ => data}/DialogCategory.java | 2 +- .../controllers/{ => data}/DialogOption.java | 3 +- .../npcs/controllers/{ => data}/Faction.java | 6 ++-- .../{ => data}/FactionOptions.java | 6 ++-- .../npcs/controllers/{ => data}/Line.java | 2 +- .../npcs/controllers/{ => data}/Lines.java | 2 +- .../{ => data}/PlayerBankData.java | 3 +- .../controllers/{ => data}/PlayerData.java | 3 +- .../{ => data}/PlayerDialogData.java | 2 +- .../{ => data}/PlayerFactionData.java | 3 +- .../{ => data}/PlayerItemGiverData.java | 2 +- .../controllers/{ => data}/PlayerMail.java | 4 +-- .../{ => data}/PlayerMailData.java | 2 +- .../{ => data}/PlayerQuestData.java | 4 ++- .../{ => data}/PlayerTransportData.java | 2 +- .../npcs/controllers/{ => data}/Quest.java | 3 +- .../controllers/{ => data}/QuestCategory.java | 2 +- .../controllers/{ => data}/QuestData.java | 2 +- .../{ => data}/RecipeCarpentry.java | 3 +- .../{ => data}/RecipesDefault.java | 4 ++- .../controllers/{ => data}/SpawnData.java | 2 +- .../controllers/{ => data}/TransformData.java | 2 +- .../{ => data}/TransportCategory.java | 2 +- .../{ => data}/TransportLocation.java | 3 +- .../npcs/entity/EntityNPCInterface.java | 15 ++++---- .../npcs/entity/data/DataSkinOverlays.java | 2 +- .../noppes/npcs/entity/data/DataTimers.java | 2 +- .../npcs/items/ItemSoulstoneFilled.java | 6 +--- .../java/noppes/npcs/quests/QuestDialog.java | 4 +-- .../noppes/npcs/quests/QuestInterface.java | 2 +- .../java/noppes/npcs/quests/QuestItem.java | 2 +- .../java/noppes/npcs/quests/QuestKill.java | 6 ++-- .../noppes/npcs/quests/QuestLocation.java | 6 ++-- .../noppes/npcs/roles/JobConversation.java | 6 ++-- .../java/noppes/npcs/roles/JobItemGiver.java | 6 ++-- src/main/java/noppes/npcs/roles/RoleBank.java | 4 +-- .../java/noppes/npcs/roles/RoleCompanion.java | 6 +--- .../noppes/npcs/roles/RoleTransporter.java | 7 ++-- .../noppes/npcs/scripted/ScriptFaction.java | 2 +- .../npcs/scripted/entity/ScriptNpc.java | 2 +- .../npcs/scripted/entity/ScriptPlayer.java | 4 +-- .../noppes/npcs/scripted/event/NpcEvent.java | 3 +- .../scripted/event/ScriptEventDialog.java | 3 +- 122 files changed, 218 insertions(+), 294 deletions(-) rename src/main/java/noppes/npcs/controllers/{ => data}/Availability.java (98%) rename src/main/java/noppes/npcs/controllers/{ => data}/Bank.java (98%) rename src/main/java/noppes/npcs/controllers/{ => data}/BankData.java (98%) rename src/main/java/noppes/npcs/controllers/{ => data}/Dialog.java (98%) rename src/main/java/noppes/npcs/controllers/{ => data}/DialogCategory.java (97%) rename src/main/java/noppes/npcs/controllers/{ => data}/DialogOption.java (94%) rename src/main/java/noppes/npcs/controllers/{ => data}/Faction.java (96%) rename src/main/java/noppes/npcs/controllers/{ => data}/FactionOptions.java (93%) rename src/main/java/noppes/npcs/controllers/{ => data}/Line.java (95%) rename src/main/java/noppes/npcs/controllers/{ => data}/Lines.java (98%) rename src/main/java/noppes/npcs/controllers/{ => data}/PlayerBankData.java (94%) rename src/main/java/noppes/npcs/controllers/{ => data}/PlayerData.java (98%) rename src/main/java/noppes/npcs/controllers/{ => data}/PlayerDialogData.java (96%) rename src/main/java/noppes/npcs/controllers/{ => data}/PlayerFactionData.java (96%) rename src/main/java/noppes/npcs/controllers/{ => data}/PlayerItemGiverData.java (97%) rename src/main/java/noppes/npcs/controllers/{ => data}/PlayerMail.java (98%) rename src/main/java/noppes/npcs/controllers/{ => data}/PlayerMailData.java (96%) rename src/main/java/noppes/npcs/controllers/{ => data}/PlayerQuestData.java (96%) rename src/main/java/noppes/npcs/controllers/{ => data}/PlayerTransportData.java (96%) rename src/main/java/noppes/npcs/controllers/{ => data}/Quest.java (98%) rename src/main/java/noppes/npcs/controllers/{ => data}/QuestCategory.java (98%) rename src/main/java/noppes/npcs/controllers/{ => data}/QuestData.java (93%) rename src/main/java/noppes/npcs/controllers/{ => data}/RecipeCarpentry.java (98%) rename src/main/java/noppes/npcs/controllers/{ => data}/RecipesDefault.java (99%) rename src/main/java/noppes/npcs/controllers/{ => data}/SpawnData.java (96%) rename src/main/java/noppes/npcs/controllers/{ => data}/TransformData.java (99%) rename src/main/java/noppes/npcs/controllers/{ => data}/TransportCategory.java (97%) rename src/main/java/noppes/npcs/controllers/{ => data}/TransportLocation.java (93%) diff --git a/src/main/java/foxz/command/CmdDialog.java b/src/main/java/foxz/command/CmdDialog.java index ee7f71857..ddca58150 100644 --- a/src/main/java/foxz/command/CmdDialog.java +++ b/src/main/java/foxz/command/CmdDialog.java @@ -1,16 +1,15 @@ package foxz.command; -import java.util.Arrays; import java.util.List; import net.minecraft.command.CommandBase; import net.minecraft.entity.player.EntityPlayer; import noppes.npcs.NoppesUtilServer; import noppes.npcs.client.EntityUtil; -import noppes.npcs.controllers.Dialog; +import noppes.npcs.controllers.data.Dialog; import noppes.npcs.controllers.DialogController; -import noppes.npcs.controllers.DialogOption; -import noppes.npcs.controllers.PlayerData; +import noppes.npcs.controllers.data.DialogOption; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.entity.EntityDialogNpc; import foxz.commandhelper.ChMcLogger; import foxz.commandhelper.annotations.Command; diff --git a/src/main/java/foxz/command/CmdFaction.java b/src/main/java/foxz/command/CmdFaction.java index fdfab8784..6733f0129 100644 --- a/src/main/java/foxz/command/CmdFaction.java +++ b/src/main/java/foxz/command/CmdFaction.java @@ -2,9 +2,9 @@ package foxz.command; import java.util.List; -import noppes.npcs.controllers.Faction; -import noppes.npcs.controllers.PlayerData; -import noppes.npcs.controllers.PlayerFactionData; +import noppes.npcs.controllers.data.Faction; +import noppes.npcs.controllers.data.PlayerData; +import noppes.npcs.controllers.data.PlayerFactionData; import foxz.commandhelper.ChMcLogger; import foxz.commandhelper.annotations.Command; import foxz.commandhelper.annotations.SubCommand; diff --git a/src/main/java/foxz/command/CmdNoppes.java b/src/main/java/foxz/command/CmdNoppes.java index 9e95fe665..8c2cc2e8c 100644 --- a/src/main/java/foxz/command/CmdNoppes.java +++ b/src/main/java/foxz/command/CmdNoppes.java @@ -25,7 +25,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentTranslation; import noppes.npcs.controllers.FactionController; -import noppes.npcs.controllers.PlayerData; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.entity.EntityNPCInterface; import foxz.commandhelper.ChMcLogger; import foxz.commandhelper.annotations.Command; diff --git a/src/main/java/foxz/command/CmdQuest.java b/src/main/java/foxz/command/CmdQuest.java index 5561b0890..d531d8943 100644 --- a/src/main/java/foxz/command/CmdQuest.java +++ b/src/main/java/foxz/command/CmdQuest.java @@ -1,20 +1,15 @@ package foxz.command; -import static foxz.utils.Utils.getOnlinePlayer; - import java.util.List; -import net.minecraft.command.PlayerSelector; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import noppes.npcs.Server; import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.controllers.DialogController; -import noppes.npcs.controllers.PlayerData; -import noppes.npcs.controllers.PlayerDataController; -import noppes.npcs.controllers.Quest; +import noppes.npcs.controllers.data.PlayerData; +import noppes.npcs.controllers.data.Quest; import noppes.npcs.controllers.QuestController; -import noppes.npcs.controllers.QuestData; +import noppes.npcs.controllers.data.QuestData; import foxz.commandhelper.ChMcLogger; import foxz.commandhelper.annotations.Command; import foxz.commandhelper.annotations.SubCommand; diff --git a/src/main/java/foxz/commandhelper/AbstractCommandHelper.java b/src/main/java/foxz/commandhelper/AbstractCommandHelper.java index f7eaf5a84..8667947fd 100644 --- a/src/main/java/foxz/commandhelper/AbstractCommandHelper.java +++ b/src/main/java/foxz/commandhelper/AbstractCommandHelper.java @@ -20,7 +20,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; -import noppes.npcs.controllers.PlayerData; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.PlayerDataController; import foxz.commandhelper.annotations.Command; import foxz.commandhelper.annotations.SubCommand; diff --git a/src/main/java/noppes/npcs/CommonProxy.java b/src/main/java/noppes/npcs/CommonProxy.java index 47e99d01d..4a8d809e8 100644 --- a/src/main/java/noppes/npcs/CommonProxy.java +++ b/src/main/java/noppes/npcs/CommonProxy.java @@ -12,8 +12,7 @@ import net.minecraftforge.common.util.FakePlayer; import noppes.npcs.blocks.tiles.TileNpcContainer; import noppes.npcs.constants.EnumGuiType; import noppes.npcs.containers.*; -import noppes.npcs.controllers.PlayerData; -import noppes.npcs.entity.EntityCustomNpc; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.entity.EntityNPCInterface; import cpw.mods.fml.common.network.IGuiHandler; import noppes.npcs.scripted.interfaces.IWorld; diff --git a/src/main/java/noppes/npcs/DataAdvanced.java b/src/main/java/noppes/npcs/DataAdvanced.java index e95962f0e..67200a374 100644 --- a/src/main/java/noppes/npcs/DataAdvanced.java +++ b/src/main/java/noppes/npcs/DataAdvanced.java @@ -6,10 +6,10 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.constants.EnumJobType; import noppes.npcs.constants.EnumRoleType; -import noppes.npcs.controllers.DialogOption; -import noppes.npcs.controllers.FactionOptions; -import noppes.npcs.controllers.Line; -import noppes.npcs.controllers.Lines; +import noppes.npcs.controllers.data.DialogOption; +import noppes.npcs.controllers.data.FactionOptions; +import noppes.npcs.controllers.data.Line; +import noppes.npcs.controllers.data.Lines; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.JobBard; import noppes.npcs.roles.JobChunkLoader; diff --git a/src/main/java/noppes/npcs/EventHooks.java b/src/main/java/noppes/npcs/EventHooks.java index 6e8d8ea7d..4da9356f7 100644 --- a/src/main/java/noppes/npcs/EventHooks.java +++ b/src/main/java/noppes/npcs/EventHooks.java @@ -20,8 +20,7 @@ import net.minecraft.world.WorldServer; import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.event.world.WorldEvent; import noppes.npcs.controllers.*; -import noppes.npcs.controllers.data.ForgeDataScript; -import noppes.npcs.controllers.data.PlayerDataScript; +import noppes.npcs.controllers.data.*; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.event.*; import noppes.npcs.scripted.event.PlayerEvent.ChatEvent; diff --git a/src/main/java/noppes/npcs/NPCSpawning.java b/src/main/java/noppes/npcs/NPCSpawning.java index c1fb610d2..56b12adf7 100644 --- a/src/main/java/noppes/npcs/NPCSpawning.java +++ b/src/main/java/noppes/npcs/NPCSpawning.java @@ -26,7 +26,7 @@ import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.event.ForgeEventFactory; import noppes.npcs.controllers.SpawnController; -import noppes.npcs.controllers.SpawnData; +import noppes.npcs.controllers.data.SpawnData; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; diff --git a/src/main/java/noppes/npcs/NoppesUtilPlayer.java b/src/main/java/noppes/npcs/NoppesUtilPlayer.java index 80af8a0d3..df129a397 100644 --- a/src/main/java/noppes/npcs/NoppesUtilPlayer.java +++ b/src/main/java/noppes/npcs/NoppesUtilPlayer.java @@ -26,6 +26,7 @@ import noppes.npcs.containers.ContainerNPCBankInterface; import noppes.npcs.containers.ContainerNPCFollower; import noppes.npcs.containers.ContainerNPCFollowerHire; import noppes.npcs.controllers.*; +import noppes.npcs.controllers.data.*; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleFollower; import cpw.mods.fml.common.network.internal.FMLProxyPacket; diff --git a/src/main/java/noppes/npcs/NoppesUtilServer.java b/src/main/java/noppes/npcs/NoppesUtilServer.java index 53e451fde..9490ca117 100644 --- a/src/main/java/noppes/npcs/NoppesUtilServer.java +++ b/src/main/java/noppes/npcs/NoppesUtilServer.java @@ -14,7 +14,6 @@ import java.util.Map; import java.util.UUID; import java.util.zip.GZIPOutputStream; -import net.minecraft.command.ICommandSender; import net.minecraft.command.server.CommandBlockLogic; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; @@ -41,34 +40,33 @@ import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumPlayerData; import noppes.npcs.constants.EnumRoleType; -import noppes.npcs.constants.EnumScriptType; import noppes.npcs.containers.ContainerManageBanks; import noppes.npcs.containers.ContainerManageRecipes; -import noppes.npcs.controllers.Bank; +import noppes.npcs.controllers.data.Bank; import noppes.npcs.controllers.BankController; -import noppes.npcs.controllers.Dialog; -import noppes.npcs.controllers.DialogCategory; +import noppes.npcs.controllers.data.Dialog; +import noppes.npcs.controllers.data.DialogCategory; import noppes.npcs.controllers.DialogController; -import noppes.npcs.controllers.DialogOption; -import noppes.npcs.controllers.Faction; +import noppes.npcs.controllers.data.DialogOption; +import noppes.npcs.controllers.data.Faction; import noppes.npcs.controllers.FactionController; -import noppes.npcs.controllers.PlayerBankData; -import noppes.npcs.controllers.PlayerData; +import noppes.npcs.controllers.data.PlayerBankData; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.PlayerDataController; -import noppes.npcs.controllers.PlayerDialogData; -import noppes.npcs.controllers.PlayerFactionData; +import noppes.npcs.controllers.data.PlayerDialogData; +import noppes.npcs.controllers.data.PlayerFactionData; import noppes.npcs.controllers.PlayerQuestController; -import noppes.npcs.controllers.PlayerQuestData; -import noppes.npcs.controllers.PlayerTransportData; -import noppes.npcs.controllers.Quest; -import noppes.npcs.controllers.QuestCategory; +import noppes.npcs.controllers.data.PlayerQuestData; +import noppes.npcs.controllers.data.PlayerTransportData; +import noppes.npcs.controllers.data.Quest; +import noppes.npcs.controllers.data.QuestCategory; import noppes.npcs.controllers.QuestController; -import noppes.npcs.controllers.RecipeCarpentry; +import noppes.npcs.controllers.data.RecipeCarpentry; import noppes.npcs.controllers.RecipeController; import noppes.npcs.controllers.ServerCloneController; -import noppes.npcs.controllers.TransportCategory; +import noppes.npcs.controllers.data.TransportCategory; import noppes.npcs.controllers.TransportController; -import noppes.npcs.controllers.TransportLocation; +import noppes.npcs.controllers.data.TransportLocation; import noppes.npcs.entity.EntityDialogNpc; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleTransporter; diff --git a/src/main/java/noppes/npcs/PacketHandlerPlayer.java b/src/main/java/noppes/npcs/PacketHandlerPlayer.java index 963a9f94c..7e0c8ae45 100644 --- a/src/main/java/noppes/npcs/PacketHandlerPlayer.java +++ b/src/main/java/noppes/npcs/PacketHandlerPlayer.java @@ -3,8 +3,6 @@ package noppes.npcs; import io.netty.buffer.ByteBuf; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; import java.util.Iterator; import net.minecraft.entity.player.EntityPlayerMP; @@ -21,6 +19,7 @@ import noppes.npcs.blocks.tiles.TileBook; import noppes.npcs.constants.*; import noppes.npcs.containers.ContainerMail; import noppes.npcs.controllers.*; +import noppes.npcs.controllers.data.*; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleCompanion; import cpw.mods.fml.common.eventhandler.SubscribeEvent; diff --git a/src/main/java/noppes/npcs/PacketHandlerServer.java b/src/main/java/noppes/npcs/PacketHandlerServer.java index c764e97ea..f15693742 100644 --- a/src/main/java/noppes/npcs/PacketHandlerServer.java +++ b/src/main/java/noppes/npcs/PacketHandlerServer.java @@ -40,9 +40,7 @@ import noppes.npcs.containers.ContainerCustomGui; import noppes.npcs.containers.ContainerMail; import noppes.npcs.controllers.*; import noppes.npcs.controllers.LinkedNpcController.LinkedData; -import noppes.npcs.controllers.data.ForgeDataScript; -import noppes.npcs.controllers.data.NPCDataScript; -import noppes.npcs.controllers.data.PlayerDataScript; +import noppes.npcs.controllers.data.*; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.JobSpawner; diff --git a/src/main/java/noppes/npcs/QuestLogData.java b/src/main/java/noppes/npcs/QuestLogData.java index a0c83726e..423da0757 100644 --- a/src/main/java/noppes/npcs/QuestLogData.java +++ b/src/main/java/noppes/npcs/QuestLogData.java @@ -6,10 +6,10 @@ import java.util.Vector; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.constants.EnumQuestCompletion; -import noppes.npcs.controllers.PlayerData; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.PlayerQuestController; -import noppes.npcs.controllers.Quest; +import noppes.npcs.controllers.data.Quest; public class QuestLogData { public HashMap> categories = new HashMap>(); diff --git a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java index 0af567230..aa6b73239 100644 --- a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java @@ -12,10 +12,7 @@ import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.relauncher.Side; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.ContainerPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.server.MinecraftServer; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; @@ -29,16 +26,15 @@ import net.minecraftforge.event.entity.living.LivingFallEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.player.*; import net.minecraftforge.event.world.*; -import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumQuestType; import noppes.npcs.controllers.*; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.PlayerDataScript; +import noppes.npcs.controllers.data.PlayerQuestData; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.entity.IPlayer; -import java.util.List; - public class ScriptPlayerEventHandler { public ScriptPlayerEventHandler() { } diff --git a/src/main/java/noppes/npcs/ServerEventsHandler.java b/src/main/java/noppes/npcs/ServerEventsHandler.java index 1d964f24c..a1294a569 100644 --- a/src/main/java/noppes/npcs/ServerEventsHandler.java +++ b/src/main/java/noppes/npcs/ServerEventsHandler.java @@ -34,8 +34,8 @@ import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumQuestType; import noppes.npcs.constants.EnumRoleType; -import noppes.npcs.constants.EnumScriptType; import noppes.npcs.controllers.*; +import noppes.npcs.controllers.data.*; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.items.ItemExcalibur; import noppes.npcs.items.ItemShield; diff --git a/src/main/java/noppes/npcs/VersionCompatibility.java b/src/main/java/noppes/npcs/VersionCompatibility.java index 90bb2479d..77e33a084 100644 --- a/src/main/java/noppes/npcs/VersionCompatibility.java +++ b/src/main/java/noppes/npcs/VersionCompatibility.java @@ -7,8 +7,8 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagInt; import net.minecraft.nbt.NBTTagList; -import noppes.npcs.controllers.Line; -import noppes.npcs.controllers.Lines; +import noppes.npcs.controllers.data.Line; +import noppes.npcs.controllers.data.Lines; import noppes.npcs.entity.EntityNPCInterface; public class VersionCompatibility { diff --git a/src/main/java/noppes/npcs/ai/EntityAIWander.java b/src/main/java/noppes/npcs/ai/EntityAIWander.java index 7913edff5..66ecd3025 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIWander.java +++ b/src/main/java/noppes/npcs/ai/EntityAIWander.java @@ -10,7 +10,7 @@ import net.minecraft.util.Vec3; import noppes.npcs.CustomNpcs; import noppes.npcs.ai.selector.NPCInteractSelector; import noppes.npcs.constants.AiMutex; -import noppes.npcs.controllers.Line; +import noppes.npcs.controllers.data.Line; import noppes.npcs.entity.EntityNPCInterface; public class EntityAIWander extends EntityAIBase diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileBorder.java b/src/main/java/noppes/npcs/blocks/tiles/TileBorder.java index 9012a168f..9eb75082a 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileBorder.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileBorder.java @@ -14,7 +14,7 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentTranslation; -import noppes.npcs.controllers.Availability; +import noppes.npcs.controllers.data.Availability; public class TileBorder extends TileEntity implements IEntitySelector{ public Availability availability = new Availability(); diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileRedstoneBlock.java b/src/main/java/noppes/npcs/blocks/tiles/TileRedstoneBlock.java index 6bd1ed8c9..224251e2c 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileRedstoneBlock.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileRedstoneBlock.java @@ -9,7 +9,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import noppes.npcs.CustomNpcs; import noppes.npcs.blocks.BlockNpcRedstone; -import noppes.npcs.controllers.Availability; +import noppes.npcs.controllers.data.Availability; public class TileRedstoneBlock extends TileEntity { public int onRange = 6; diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileWaypoint.java b/src/main/java/noppes/npcs/blocks/tiles/TileWaypoint.java index 5d8b5914a..e57b3e99b 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileWaypoint.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileWaypoint.java @@ -10,10 +10,10 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.StatCollector; import noppes.npcs.constants.EnumQuestType; -import noppes.npcs.controllers.PlayerData; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.PlayerDataController; -import noppes.npcs.controllers.PlayerQuestData; -import noppes.npcs.controllers.QuestData; +import noppes.npcs.controllers.data.PlayerQuestData; +import noppes.npcs.controllers.data.QuestData; import noppes.npcs.quests.QuestLocation; public class TileWaypoint extends TileEntity { diff --git a/src/main/java/noppes/npcs/client/ClientProxy.java b/src/main/java/noppes/npcs/client/ClientProxy.java index c663c371d..22b555211 100644 --- a/src/main/java/noppes/npcs/client/ClientProxy.java +++ b/src/main/java/noppes/npcs/client/ClientProxy.java @@ -131,7 +131,7 @@ import noppes.npcs.client.renderer.blocks.BlockWeaponRackRenderer; import noppes.npcs.config.StringCache; import noppes.npcs.constants.EnumGuiType; import noppes.npcs.containers.*; -import noppes.npcs.controllers.PlayerData; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.entity.*; import noppes.npcs.items.ItemScripted; diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index 52e92a78c..2c41363b8 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -33,9 +33,9 @@ import noppes.npcs.client.gui.util.IScrollData; import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.constants.EnumPlayerPacket; -import noppes.npcs.controllers.Dialog; +import noppes.npcs.controllers.data.Dialog; import noppes.npcs.controllers.DialogController; -import noppes.npcs.controllers.Quest; +import noppes.npcs.controllers.data.Quest; import noppes.npcs.controllers.data.SkinOverlay; import noppes.npcs.entity.EntityNPCInterface; diff --git a/src/main/java/noppes/npcs/client/PacketHandlerClient.java b/src/main/java/noppes/npcs/client/PacketHandlerClient.java index 607abd189..023dba9b7 100644 --- a/src/main/java/noppes/npcs/client/PacketHandlerClient.java +++ b/src/main/java/noppes/npcs/client/PacketHandlerClient.java @@ -36,7 +36,7 @@ import noppes.npcs.client.gui.util.IGuiError; import noppes.npcs.client.gui.util.IScrollData; import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumPacketClient; -import noppes.npcs.controllers.RecipeCarpentry; +import noppes.npcs.controllers.data.RecipeCarpentry; import noppes.npcs.controllers.RecipeController; import noppes.npcs.entity.EntityDialogNpc; import noppes.npcs.entity.EntityNPCInterface; diff --git a/src/main/java/noppes/npcs/client/gui/GuiNPCLinesEdit.java b/src/main/java/noppes/npcs/client/gui/GuiNPCLinesEdit.java index d0bb5920b..ab3a1674d 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNPCLinesEdit.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNPCLinesEdit.java @@ -11,8 +11,8 @@ import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.client.gui.util.IGuiData; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.Line; -import noppes.npcs.controllers.Lines; +import noppes.npcs.controllers.data.Line; +import noppes.npcs.controllers.data.Lines; import noppes.npcs.entity.EntityNPCInterface; public class GuiNPCLinesEdit extends GuiNPCInterface2 implements IGuiData diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiMailmanSendSetup.java b/src/main/java/noppes/npcs/client/gui/SubGuiMailmanSendSetup.java index 2d065fa7b..8c0e5316a 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiMailmanSendSetup.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiMailmanSendSetup.java @@ -15,7 +15,7 @@ import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.containers.ContainerMail; -import noppes.npcs.controllers.PlayerMail; +import noppes.npcs.controllers.data.PlayerMail; public class SubGuiMailmanSendSetup extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener{ diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailability.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailability.java index a1708aa89..bcd12d257 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailability.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailability.java @@ -14,8 +14,8 @@ import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.constants.EnumAvailabilityFactionType; import noppes.npcs.constants.EnumDayTime; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.Availability; -import noppes.npcs.controllers.Faction; +import noppes.npcs.controllers.data.Availability; +import noppes.npcs.controllers.data.Faction; public class SubGuiNpcAvailability extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener, IGuiData { diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityDialog.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityDialog.java index 65814d72d..c08f83434 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityDialog.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityDialog.java @@ -1,7 +1,6 @@ package noppes.npcs.client.gui; import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreen; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.client.Client; import noppes.npcs.client.NoppesUtil; @@ -12,8 +11,8 @@ import noppes.npcs.client.gui.util.IGuiData; import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.constants.EnumAvailabilityDialog; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.Availability; -import noppes.npcs.controllers.Dialog; +import noppes.npcs.controllers.data.Availability; +import noppes.npcs.controllers.data.Dialog; public class SubGuiNpcAvailabilityDialog extends SubGuiInterface implements GuiSelectionListener, IGuiData{ private Availability availabitily; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityQuest.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityQuest.java index 33094b7d9..902bb3ce1 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityQuest.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailabilityQuest.java @@ -1,7 +1,6 @@ package noppes.npcs.client.gui; import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreen; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.client.Client; import noppes.npcs.client.NoppesUtil; @@ -13,8 +12,8 @@ import noppes.npcs.client.gui.util.IGuiData; import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.constants.EnumAvailabilityQuest; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.Availability; -import noppes.npcs.controllers.Quest; +import noppes.npcs.controllers.data.Availability; +import noppes.npcs.controllers.data.Quest; public class SubGuiNpcAvailabilityQuest extends SubGuiInterface implements GuiSelectionListener, IGuiData { private Availability availabitily; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java index e91743ca6..c4993d393 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java @@ -5,19 +5,11 @@ import java.util.List; import net.minecraft.client.gui.GuiButton; import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.biome.BiomeGenMutated; -import net.minecraftforge.common.BiomeManager; -import noppes.npcs.DataAI; import noppes.npcs.client.gui.util.GuiCustomScroll; import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.client.gui.util.SubGuiInterface; -import noppes.npcs.constants.EnumAnimation; -import noppes.npcs.constants.EnumMovingType; -import noppes.npcs.constants.EnumStandingType; -import noppes.npcs.controllers.SpawnData; +import noppes.npcs.controllers.data.SpawnData; public class SubGuiNpcBiomes extends SubGuiInterface { diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogExtra.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogExtra.java index 3c20cc863..5fc09c88c 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogExtra.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogExtra.java @@ -2,21 +2,14 @@ package noppes.npcs.client.gui; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.client.Client; import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcButtonYesNo; import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiSelectionListener; -import noppes.npcs.client.gui.util.IGuiData; import noppes.npcs.client.gui.util.ISubGuiListener; import noppes.npcs.client.gui.util.SubGuiInterface; -import noppes.npcs.constants.EnumAvailabilityDialog; -import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.Availability; -import noppes.npcs.controllers.Dialog; -import noppes.npcs.controllers.PlayerMail; +import noppes.npcs.controllers.data.Dialog; +import noppes.npcs.controllers.data.PlayerMail; public class SubGuiNpcDialogExtra extends SubGuiInterface implements ISubGuiListener { diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOption.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOption.java index 3b24c9bc7..41f000a03 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOption.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOption.java @@ -14,8 +14,8 @@ import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.constants.EnumOptionType; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.Dialog; -import noppes.npcs.controllers.DialogOption; +import noppes.npcs.controllers.data.Dialog; +import noppes.npcs.controllers.data.DialogOption; public class SubGuiNpcDialogOption extends SubGuiInterface implements IGuiData, ITextfieldListener, GuiSelectionListener, ISubGuiListener{ private DialogOption option; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOptions.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOptions.java index ed2cf708b..7e97d55b3 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOptions.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogOptions.java @@ -5,8 +5,8 @@ import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.constants.EnumOptionType; -import noppes.npcs.controllers.Dialog; -import noppes.npcs.controllers.DialogOption; +import noppes.npcs.controllers.data.Dialog; +import noppes.npcs.controllers.data.DialogOption; public class SubGuiNpcDialogOptions extends SubGuiInterface { diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionOptions.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionOptions.java index 4f4fa1469..4a1c543f5 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionOptions.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionOptions.java @@ -14,7 +14,7 @@ import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.client.gui.util.IScrollData; import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.FactionOptions; +import noppes.npcs.controllers.data.FactionOptions; public class SubGuiNpcFactionOptions extends SubGuiInterface implements IScrollData,ICustomScrollListener { diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionPoints.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionPoints.java index 0f018ea15..4e6ee1ef0 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionPoints.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionPoints.java @@ -7,7 +7,7 @@ import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.client.gui.util.SubGuiInterface; -import noppes.npcs.controllers.Faction; +import noppes.npcs.controllers.data.Faction; public class SubGuiNpcFactionPoints extends SubGuiInterface implements ITextfieldListener { diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAdvancedLinkedNpc.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAdvancedLinkedNpc.java index 1c61e8a52..37e4e88b6 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAdvancedLinkedNpc.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAdvancedLinkedNpc.java @@ -5,32 +5,15 @@ import java.util.HashMap; import java.util.List; import java.util.Vector; -import org.apache.logging.log4j.status.StatusConsoleListener; - import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.StatCollector; import noppes.npcs.client.Client; -import noppes.npcs.client.gui.SubGuiEditText; -import noppes.npcs.client.gui.SubGuiMailmanSendSetup; -import noppes.npcs.client.gui.SubGuiNpcCommand; -import noppes.npcs.client.gui.SubGuiNpcFactionOptions; -import noppes.npcs.client.gui.SubGuiNpcTextArea; import noppes.npcs.client.gui.util.GuiCustomScroll; import noppes.npcs.client.gui.util.GuiNPCInterface2; import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.GuiSelectionListener; import noppes.npcs.client.gui.util.ICustomScrollListener; -import noppes.npcs.client.gui.util.IGuiData; import noppes.npcs.client.gui.util.IScrollData; -import noppes.npcs.client.gui.util.ISubGuiListener; -import noppes.npcs.client.gui.util.ITextfieldListener; -import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.Quest; -import noppes.npcs.controllers.QuestCategory; import noppes.npcs.entity.EntityNPCInterface; public class GuiNPCAdvancedLinkedNpc extends GuiNPCInterface2 implements IScrollData, ICustomScrollListener{ diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCDialogNpcOptions.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCDialogNpcOptions.java index 1eda4f0f5..7617508e3 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCDialogNpcOptions.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCDialogNpcOptions.java @@ -14,7 +14,7 @@ import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.GuiSelectionListener; import noppes.npcs.client.gui.util.IGuiData; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.DialogOption; +import noppes.npcs.controllers.data.DialogOption; import noppes.npcs.entity.EntityNPCInterface; diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCNightSetup.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCNightSetup.java index 1ea39adab..75b14dce9 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCNightSetup.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCNightSetup.java @@ -8,7 +8,7 @@ import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.IGuiData; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.TransformData; +import noppes.npcs.controllers.data.TransformData; import noppes.npcs.entity.EntityNPCInterface; public class GuiNPCNightSetup extends GuiNPCInterface2 implements IGuiData diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageBanks.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageBanks.java index 0a544a5cb..ad8888012 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageBanks.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageBanks.java @@ -17,7 +17,7 @@ import noppes.npcs.client.gui.util.IScrollData; import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.containers.ContainerManageBanks; -import noppes.npcs.controllers.Bank; +import noppes.npcs.controllers.data.Bank; import noppes.npcs.entity.EntityNPCInterface; public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScrollData,ICustomScrollListener,ITextfieldListener, IGuiData diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java index 6594864e2..77d9025b8 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageDialogs.java @@ -8,11 +8,8 @@ import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.client.Client; import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.gui.GuiNpcSoundSelection; -import noppes.npcs.client.gui.SubGuiMailmanSendSetup; import noppes.npcs.client.gui.SubGuiNpcAvailability; -import noppes.npcs.client.gui.SubGuiNpcCommand; import noppes.npcs.client.gui.SubGuiNpcDialogExtra; -import noppes.npcs.client.gui.SubGuiNpcDialogOption; import noppes.npcs.client.gui.SubGuiNpcDialogOptions; import noppes.npcs.client.gui.SubGuiNpcFactionOptions; import noppes.npcs.client.gui.SubGuiNpcTextArea; @@ -29,9 +26,8 @@ import noppes.npcs.client.gui.util.ISubGuiListener; import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.Dialog; -import noppes.npcs.controllers.DialogCategory; -import noppes.npcs.controllers.PlayerMail; +import noppes.npcs.controllers.data.Dialog; +import noppes.npcs.controllers.data.DialogCategory; import noppes.npcs.entity.EntityNPCInterface; public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollData, ISubGuiListener, GuiSelectionListener,ICustomScrollListener,ITextfieldListener, IGuiData diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageFactions.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageFactions.java index b1dac2e2f..0a0f756dd 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageFactions.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageFactions.java @@ -22,7 +22,7 @@ import noppes.npcs.client.gui.util.ISubGuiListener; import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.Faction; +import noppes.npcs.controllers.data.Faction; import noppes.npcs.entity.EntityNPCInterface; public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollData,ICustomScrollListener,ITextfieldListener, IGuiData, ISubGuiListener diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageLinkedNpc.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageLinkedNpc.java index 447985566..3eeaf2d99 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageLinkedNpc.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageLinkedNpc.java @@ -5,32 +5,17 @@ import java.util.HashMap; import java.util.List; import java.util.Vector; -import org.apache.logging.log4j.status.StatusConsoleListener; - import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.StatCollector; import noppes.npcs.client.Client; import noppes.npcs.client.gui.SubGuiEditText; -import noppes.npcs.client.gui.SubGuiMailmanSendSetup; -import noppes.npcs.client.gui.SubGuiNpcCommand; -import noppes.npcs.client.gui.SubGuiNpcFactionOptions; -import noppes.npcs.client.gui.SubGuiNpcTextArea; import noppes.npcs.client.gui.util.GuiCustomScroll; import noppes.npcs.client.gui.util.GuiNPCInterface2; import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.GuiSelectionListener; -import noppes.npcs.client.gui.util.ICustomScrollListener; -import noppes.npcs.client.gui.util.IGuiData; import noppes.npcs.client.gui.util.IScrollData; import noppes.npcs.client.gui.util.ISubGuiListener; -import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.Quest; -import noppes.npcs.controllers.QuestCategory; import noppes.npcs.entity.EntityNPCInterface; public class GuiNPCManageLinkedNpc extends GuiNPCInterface2 implements IScrollData, ISubGuiListener{ diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java index 07c1f94bc..2bda9c993 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageQuest.java @@ -7,7 +7,6 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.client.Client; -import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.gui.SubGuiMailmanSendSetup; import noppes.npcs.client.gui.SubGuiNpcCommand; import noppes.npcs.client.gui.SubGuiNpcFactionOptions; @@ -32,9 +31,8 @@ import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.constants.EnumQuestCompletion; import noppes.npcs.constants.EnumQuestRepeat; import noppes.npcs.constants.EnumQuestType; -import noppes.npcs.controllers.PlayerMail; -import noppes.npcs.controllers.Quest; -import noppes.npcs.controllers.QuestCategory; +import noppes.npcs.controllers.data.Quest; +import noppes.npcs.controllers.data.QuestCategory; import noppes.npcs.entity.EntityNPCInterface; public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollData, ISubGuiListener, GuiSelectionListener,ICustomScrollListener,ITextfieldListener, IGuiData diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java index dc598c01a..ed8cf2fc2 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java @@ -21,7 +21,7 @@ import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.containers.ContainerManageRecipes; -import noppes.npcs.controllers.RecipeCarpentry; +import noppes.npcs.controllers.data.RecipeCarpentry; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNpcNaturalSpawns.java b/src/main/java/noppes/npcs/client/gui/global/GuiNpcNaturalSpawns.java index 33f896870..6865e1a2d 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNpcNaturalSpawns.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNpcNaturalSpawns.java @@ -22,7 +22,7 @@ import noppes.npcs.client.gui.util.ISliderListener; import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.SpawnData; +import noppes.npcs.controllers.data.SpawnData; import noppes.npcs.entity.EntityNPCInterface; public class GuiNpcNaturalSpawns extends GuiNPCInterface2 implements IGuiData, IScrollData, ITextfieldListener, ICustomScrollListener, ISliderListener{ diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNpcQuestReward.java b/src/main/java/noppes/npcs/client/gui/global/GuiNpcQuestReward.java index 2a0d5bd3c..072b5ee07 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNpcQuestReward.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNpcQuestReward.java @@ -9,7 +9,7 @@ import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.containers.ContainerNpcQuestReward; -import noppes.npcs.controllers.Quest; +import noppes.npcs.controllers.data.Quest; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/noppes/npcs/client/gui/global/SubGuiNpcQuestAdvanced.java b/src/main/java/noppes/npcs/client/gui/global/SubGuiNpcQuestAdvanced.java index ed4b9616d..557afa0dd 100644 --- a/src/main/java/noppes/npcs/client/gui/global/SubGuiNpcQuestAdvanced.java +++ b/src/main/java/noppes/npcs/client/gui/global/SubGuiNpcQuestAdvanced.java @@ -10,11 +10,8 @@ import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.client.gui.util.SubGuiInterface; -import noppes.npcs.constants.EnumAnimation; -import noppes.npcs.constants.EnumMovingType; -import noppes.npcs.constants.EnumStandingType; -import noppes.npcs.controllers.PlayerMail; -import noppes.npcs.controllers.Quest; +import noppes.npcs.controllers.data.PlayerMail; +import noppes.npcs.controllers.data.Quest; public class SubGuiNpcQuestAdvanced extends SubGuiInterface implements ITextfieldListener { diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java b/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java index 20740533c..142fc1127 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java @@ -21,8 +21,8 @@ import noppes.npcs.client.gui.util.GuiNPCInterface; import noppes.npcs.client.gui.util.IGuiClose; import noppes.npcs.constants.EnumOptionType; import noppes.npcs.constants.EnumPlayerPacket; -import noppes.npcs.controllers.Dialog; -import noppes.npcs.controllers.DialogOption; +import noppes.npcs.controllers.data.Dialog; +import noppes.npcs.controllers.data.DialogOption; import noppes.npcs.entity.EntityNPCInterface; import org.lwjgl.input.Keyboard; diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiFaction.java b/src/main/java/noppes/npcs/client/gui/player/GuiFaction.java index 8151df430..5b4ea3590 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiFaction.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiFaction.java @@ -13,8 +13,8 @@ import noppes.npcs.client.gui.util.GuiButtonNextPage; import noppes.npcs.client.gui.util.GuiNPCInterface; import noppes.npcs.client.gui.util.IGuiData; import noppes.npcs.constants.EnumPlayerPacket; -import noppes.npcs.controllers.Faction; -import noppes.npcs.controllers.PlayerFactionData; +import noppes.npcs.controllers.data.Faction; +import noppes.npcs.controllers.data.PlayerFactionData; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiMailbox.java b/src/main/java/noppes/npcs/client/gui/player/GuiMailbox.java index a345fd0a0..5306b4def 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiMailbox.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiMailbox.java @@ -19,8 +19,8 @@ import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.ICustomScrollListener; import noppes.npcs.client.gui.util.IGuiData; import noppes.npcs.constants.EnumPlayerPacket; -import noppes.npcs.controllers.PlayerMail; -import noppes.npcs.controllers.PlayerMailData; +import noppes.npcs.controllers.data.PlayerMail; +import noppes.npcs.controllers.data.PlayerMailData; public class GuiMailbox extends GuiNPCInterface implements IGuiData, ICustomScrollListener, GuiYesNoCallback{ diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiMailmanWrite.java b/src/main/java/noppes/npcs/client/gui/player/GuiMailmanWrite.java index bccb11d4e..46909fd8c 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiMailmanWrite.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiMailmanWrite.java @@ -26,7 +26,7 @@ import noppes.npcs.client.gui.util.IGuiError; import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.constants.EnumPlayerPacket; import noppes.npcs.containers.ContainerMail; -import noppes.npcs.controllers.PlayerMail; +import noppes.npcs.controllers.data.PlayerMail; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiQuestCompletion.java b/src/main/java/noppes/npcs/client/gui/player/GuiQuestCompletion.java index 4e689ac0b..7a089c6d2 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiQuestCompletion.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiQuestCompletion.java @@ -3,7 +3,6 @@ package noppes.npcs.client.gui.player; import net.minecraft.client.gui.GuiButton; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; -import noppes.npcs.NoppesStringUtils; import noppes.npcs.NoppesUtilPlayer; import noppes.npcs.client.CustomNpcResourceListener; import noppes.npcs.client.TextBlockClient; @@ -12,7 +11,7 @@ import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.ITopButtonListener; import noppes.npcs.constants.EnumPlayerPacket; -import noppes.npcs.controllers.Quest; +import noppes.npcs.controllers.data.Quest; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiRecipes.java b/src/main/java/noppes/npcs/client/gui/player/GuiRecipes.java index f41060706..0348bba47 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiRecipes.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiRecipes.java @@ -1,7 +1,6 @@ package noppes.npcs.client.gui.player; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import org.lwjgl.opengl.GL11; @@ -18,7 +17,7 @@ import noppes.npcs.client.gui.util.GuiButtonNextPage; import noppes.npcs.client.gui.util.GuiNPCInterface; import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.controllers.RecipeCarpentry; +import noppes.npcs.controllers.data.RecipeCarpentry; import noppes.npcs.controllers.RecipeController; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; diff --git a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeDialog.java b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeDialog.java index 1f0b321b9..f4e7694cb 100644 --- a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeDialog.java +++ b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeDialog.java @@ -8,13 +8,12 @@ import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.client.Client; import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.gui.GuiNPCDialogSelection; -import noppes.npcs.client.gui.util.GuiNPCInterface; import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiSelectionListener; import noppes.npcs.client.gui.util.IGuiData; import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.Quest; +import noppes.npcs.controllers.data.Quest; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.quests.QuestDialog; diff --git a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeItem.java b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeItem.java index 7b2ef8221..87a3297f3 100644 --- a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeItem.java +++ b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeItem.java @@ -11,7 +11,7 @@ import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.containers.ContainerNpcQuestTypeItem; -import noppes.npcs.controllers.Quest; +import noppes.npcs.controllers.data.Quest; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.quests.QuestItem; diff --git a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java index 0e1dc39e1..f903a3d77 100644 --- a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java +++ b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java @@ -17,7 +17,7 @@ import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.client.gui.util.SubGuiInterface; -import noppes.npcs.controllers.Quest; +import noppes.npcs.controllers.data.Quest; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.quests.QuestKill; diff --git a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeLocation.java b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeLocation.java index 04c6c66cf..879ee0eae 100644 --- a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeLocation.java +++ b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeLocation.java @@ -2,13 +2,12 @@ package noppes.npcs.client.gui.questtypes; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; -import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.client.gui.util.SubGuiInterface; -import noppes.npcs.controllers.Quest; +import noppes.npcs.controllers.data.Quest; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.quests.QuestLocation; diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBankSetup.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBankSetup.java index 14dd9ccb5..10b433b1f 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBankSetup.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBankSetup.java @@ -11,7 +11,7 @@ import noppes.npcs.client.gui.util.ICustomScrollListener; import noppes.npcs.client.gui.util.GuiNPCInterface2; import noppes.npcs.client.gui.util.IScrollData; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.Bank; +import noppes.npcs.controllers.data.Bank; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleBank; diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTransporter.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTransporter.java index b3c93a8e3..523ebc295 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTransporter.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTransporter.java @@ -6,19 +6,15 @@ import java.util.Vector; import net.minecraft.client.gui.GuiButton; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.client.Client; -import noppes.npcs.client.NoppesUtil; -import noppes.npcs.client.gui.mainmenu.GuiNpcAdvanced; import noppes.npcs.client.gui.util.GuiCustomScroll; -import noppes.npcs.client.gui.util.GuiNPCInterface; import noppes.npcs.client.gui.util.GuiNPCInterface2; -import noppes.npcs.client.gui.util.GuiNPCStringSlot; import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.GuiNpcTextField; import noppes.npcs.client.gui.util.IGuiData; import noppes.npcs.client.gui.util.IScrollData; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.TransportLocation; +import noppes.npcs.controllers.data.TransportLocation; import noppes.npcs.entity.EntityNPCInterface; public class GuiNpcTransporter extends GuiNPCInterface2 implements IScrollData, IGuiData{ diff --git a/src/main/java/noppes/npcs/containers/ContainerCarpentryBench.java b/src/main/java/noppes/npcs/containers/ContainerCarpentryBench.java index a6cf8cf8c..1abf5cb16 100644 --- a/src/main/java/noppes/npcs/containers/ContainerCarpentryBench.java +++ b/src/main/java/noppes/npcs/containers/ContainerCarpentryBench.java @@ -13,7 +13,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.network.play.server.S2FPacketSetSlot; import net.minecraft.world.World; import noppes.npcs.CustomItems; -import noppes.npcs.controllers.RecipeCarpentry; +import noppes.npcs.controllers.data.RecipeCarpentry; import noppes.npcs.controllers.RecipeController; public class ContainerCarpentryBench extends Container diff --git a/src/main/java/noppes/npcs/containers/ContainerMail.java b/src/main/java/noppes/npcs/containers/ContainerMail.java index c2e2a6f2c..b6b268225 100644 --- a/src/main/java/noppes/npcs/containers/ContainerMail.java +++ b/src/main/java/noppes/npcs/containers/ContainerMail.java @@ -3,18 +3,11 @@ package noppes.npcs.containers; import java.util.Iterator; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ContainerChest; -import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import net.minecraft.util.MathHelper; -import noppes.npcs.CustomNpcs; -import noppes.npcs.client.gui.player.GuiMailmanWrite; -import noppes.npcs.constants.EnumGuiType; import noppes.npcs.controllers.PlayerDataController; -import noppes.npcs.controllers.PlayerMail; -import noppes.npcs.controllers.PlayerMailData; +import noppes.npcs.controllers.data.PlayerMail; +import noppes.npcs.controllers.data.PlayerMailData; public class ContainerMail extends ContainerNpcInterface{ private static final String __OBFID = "CL_00001742"; diff --git a/src/main/java/noppes/npcs/containers/ContainerManageBanks.java b/src/main/java/noppes/npcs/containers/ContainerManageBanks.java index e83eb490e..f95e11378 100644 --- a/src/main/java/noppes/npcs/containers/ContainerManageBanks.java +++ b/src/main/java/noppes/npcs/containers/ContainerManageBanks.java @@ -4,7 +4,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import noppes.npcs.controllers.Bank; +import noppes.npcs.controllers.data.Bank; public class ContainerManageBanks extends Container { diff --git a/src/main/java/noppes/npcs/containers/ContainerManageRecipes.java b/src/main/java/noppes/npcs/containers/ContainerManageRecipes.java index b11209893..905cfd3b1 100644 --- a/src/main/java/noppes/npcs/containers/ContainerManageRecipes.java +++ b/src/main/java/noppes/npcs/containers/ContainerManageRecipes.java @@ -10,7 +10,7 @@ import net.minecraft.inventory.InventoryBasic; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import noppes.npcs.NoppesUtilPlayer; -import noppes.npcs.controllers.RecipeCarpentry; +import noppes.npcs.controllers.data.RecipeCarpentry; public class ContainerManageRecipes extends Container { diff --git a/src/main/java/noppes/npcs/containers/ContainerNPCBankInterface.java b/src/main/java/noppes/npcs/containers/ContainerNPCBankInterface.java index 72d582643..acca8a9aa 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNPCBankInterface.java +++ b/src/main/java/noppes/npcs/containers/ContainerNPCBankInterface.java @@ -1,12 +1,11 @@ package noppes.npcs.containers; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import noppes.npcs.NpcMiscInventory; -import noppes.npcs.controllers.PlayerBankData; +import noppes.npcs.controllers.data.PlayerBankData; import noppes.npcs.controllers.PlayerDataController; public class ContainerNPCBankInterface extends ContainerNpcInterface diff --git a/src/main/java/noppes/npcs/containers/ContainerNpcQuestReward.java b/src/main/java/noppes/npcs/containers/ContainerNpcQuestReward.java index ce8103eb6..af9199c31 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNpcQuestReward.java +++ b/src/main/java/noppes/npcs/containers/ContainerNpcQuestReward.java @@ -6,7 +6,7 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import noppes.npcs.NoppesUtilServer; import noppes.npcs.client.gui.global.GuiNPCManageQuest; -import noppes.npcs.controllers.Quest; +import noppes.npcs.controllers.data.Quest; public class ContainerNpcQuestReward extends Container{ public ContainerNpcQuestReward(EntityPlayer player){ diff --git a/src/main/java/noppes/npcs/containers/ContainerNpcQuestTypeItem.java b/src/main/java/noppes/npcs/containers/ContainerNpcQuestTypeItem.java index 274dc6c53..797412633 100644 --- a/src/main/java/noppes/npcs/containers/ContainerNpcQuestTypeItem.java +++ b/src/main/java/noppes/npcs/containers/ContainerNpcQuestTypeItem.java @@ -6,7 +6,7 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import noppes.npcs.NoppesUtilServer; import noppes.npcs.client.gui.global.GuiNPCManageQuest; -import noppes.npcs.controllers.Quest; +import noppes.npcs.controllers.data.Quest; import noppes.npcs.quests.QuestItem; public class ContainerNpcQuestTypeItem extends Container diff --git a/src/main/java/noppes/npcs/controllers/BankController.java b/src/main/java/noppes/npcs/controllers/BankController.java index beb5ca5ce..45c7da78c 100644 --- a/src/main/java/noppes/npcs/controllers/BankController.java +++ b/src/main/java/noppes/npcs/controllers/BankController.java @@ -1,20 +1,16 @@ package noppes.npcs.controllers; -import io.netty.buffer.ByteBufInputStream; - -import java.io.BufferedInputStream; -import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.HashMap; -import java.util.zip.GZIPInputStream; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.CustomNpcs; +import noppes.npcs.controllers.data.Bank; public class BankController { public HashMap banks; diff --git a/src/main/java/noppes/npcs/controllers/DialogController.java b/src/main/java/noppes/npcs/controllers/DialogController.java index 9791ca720..19f86659e 100644 --- a/src/main/java/noppes/npcs/controllers/DialogController.java +++ b/src/main/java/noppes/npcs/controllers/DialogController.java @@ -11,6 +11,9 @@ import noppes.npcs.CustomNpcs; import noppes.npcs.LogWriter; import noppes.npcs.NoppesStringUtils; import noppes.npcs.constants.EnumOptionType; +import noppes.npcs.controllers.data.Dialog; +import noppes.npcs.controllers.data.DialogCategory; +import noppes.npcs.controllers.data.DialogOption; import noppes.npcs.scripted.interfaces.handler.IDialogHandler; import noppes.npcs.scripted.interfaces.handler.data.IDialog; import noppes.npcs.scripted.interfaces.handler.data.IDialogCategory; diff --git a/src/main/java/noppes/npcs/controllers/FactionController.java b/src/main/java/noppes/npcs/controllers/FactionController.java index 5b59d349a..d284b65a4 100644 --- a/src/main/java/noppes/npcs/controllers/FactionController.java +++ b/src/main/java/noppes/npcs/controllers/FactionController.java @@ -17,6 +17,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.CustomNpcs; import noppes.npcs.LogWriter; +import noppes.npcs.controllers.data.Faction; import noppes.npcs.scripted.interfaces.handler.IFactionHandler; import noppes.npcs.scripted.interfaces.handler.data.IFaction; diff --git a/src/main/java/noppes/npcs/controllers/PlayerDataController.java b/src/main/java/noppes/npcs/controllers/PlayerDataController.java index 621de7d7d..e3b929502 100644 --- a/src/main/java/noppes/npcs/controllers/PlayerDataController.java +++ b/src/main/java/noppes/npcs/controllers/PlayerDataController.java @@ -1,10 +1,7 @@ package noppes.npcs.controllers; -import java.io.EOFException; import java.io.File; import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -14,6 +11,10 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.server.MinecraftServer; import noppes.npcs.CustomNpcs; import noppes.npcs.LogWriter; +import noppes.npcs.controllers.data.Bank; +import noppes.npcs.controllers.data.PlayerBankData; +import noppes.npcs.controllers.data.PlayerData; +import noppes.npcs.controllers.data.PlayerMail; import noppes.npcs.util.NBTJsonUtil; public class PlayerDataController { diff --git a/src/main/java/noppes/npcs/controllers/PlayerQuestController.java b/src/main/java/noppes/npcs/controllers/PlayerQuestController.java index 0a4172b7c..16c63431f 100644 --- a/src/main/java/noppes/npcs/controllers/PlayerQuestController.java +++ b/src/main/java/noppes/npcs/controllers/PlayerQuestController.java @@ -9,6 +9,10 @@ import noppes.npcs.Server; import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumQuestRepeat; import noppes.npcs.constants.EnumQuestType; +import noppes.npcs.controllers.data.PlayerData; +import noppes.npcs.controllers.data.PlayerQuestData; +import noppes.npcs.controllers.data.Quest; +import noppes.npcs.controllers.data.QuestData; import noppes.npcs.quests.QuestDialog; public class PlayerQuestController { @@ -35,7 +39,7 @@ public class PlayerQuestController { return; } - data.activeQuests.put(quest.id,new QuestData(quest)); + data.activeQuests.put(quest.id,new QuestData(quest)); Server.sendData((EntityPlayerMP)player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title); Server.sendData((EntityPlayerMP)player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title); } diff --git a/src/main/java/noppes/npcs/controllers/QuestController.java b/src/main/java/noppes/npcs/controllers/QuestController.java index 70a28819f..194ae3f17 100644 --- a/src/main/java/noppes/npcs/controllers/QuestController.java +++ b/src/main/java/noppes/npcs/controllers/QuestController.java @@ -10,6 +10,8 @@ import net.minecraft.nbt.NBTTagList; import noppes.npcs.CustomNpcs; import noppes.npcs.LogWriter; import noppes.npcs.NoppesStringUtils; +import noppes.npcs.controllers.data.Quest; +import noppes.npcs.controllers.data.QuestCategory; import noppes.npcs.scripted.interfaces.handler.IQuestHandler; import noppes.npcs.scripted.interfaces.handler.data.IQuest; import noppes.npcs.scripted.interfaces.handler.data.IQuestCategory; diff --git a/src/main/java/noppes/npcs/controllers/RecipeController.java b/src/main/java/noppes/npcs/controllers/RecipeController.java index b503490fd..550e1924e 100644 --- a/src/main/java/noppes/npcs/controllers/RecipeController.java +++ b/src/main/java/noppes/npcs/controllers/RecipeController.java @@ -13,6 +13,8 @@ import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.CustomNpcs; +import noppes.npcs.controllers.data.RecipeCarpentry; +import noppes.npcs.controllers.data.RecipesDefault; import noppes.npcs.scripted.interfaces.handler.IRecipeHandler; import noppes.npcs.scripted.interfaces.handler.data.IRecipe; @@ -75,7 +77,7 @@ public class RecipeController implements IRecipeHandler { private void loadDefaultRecipes(int i) { if(i == version) return; - RecipesDefault.loadDefaultRecipes(i); + RecipesDefault.loadDefaultRecipes(i); saveCategories(); } diff --git a/src/main/java/noppes/npcs/controllers/SpawnController.java b/src/main/java/noppes/npcs/controllers/SpawnController.java index 825422ed8..3b25e002e 100644 --- a/src/main/java/noppes/npcs/controllers/SpawnController.java +++ b/src/main/java/noppes/npcs/controllers/SpawnController.java @@ -19,6 +19,7 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.util.WeightedRandom; import noppes.npcs.CustomNpcs; import noppes.npcs.LogWriter; +import noppes.npcs.controllers.data.SpawnData; public class SpawnController { public HashMap> biomes = new HashMap>() ; diff --git a/src/main/java/noppes/npcs/controllers/TransportController.java b/src/main/java/noppes/npcs/controllers/TransportController.java index e2beb1a20..b84371c4b 100644 --- a/src/main/java/noppes/npcs/controllers/TransportController.java +++ b/src/main/java/noppes/npcs/controllers/TransportController.java @@ -1,13 +1,10 @@ package noppes.npcs.controllers; -import java.io.BufferedInputStream; -import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.HashMap; -import java.util.zip.GZIPInputStream; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.CompressedStreamTools; @@ -16,6 +13,8 @@ import net.minecraft.nbt.NBTTagList; import noppes.npcs.CustomNpcs; import noppes.npcs.LogWriter; import noppes.npcs.constants.EnumRoleType; +import noppes.npcs.controllers.data.TransportCategory; +import noppes.npcs.controllers.data.TransportLocation; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleTransporter; diff --git a/src/main/java/noppes/npcs/controllers/Availability.java b/src/main/java/noppes/npcs/controllers/data/Availability.java similarity index 98% rename from src/main/java/noppes/npcs/controllers/Availability.java rename to src/main/java/noppes/npcs/controllers/data/Availability.java index f20c0ed33..2e85aa7b7 100644 --- a/src/main/java/noppes/npcs/controllers/Availability.java +++ b/src/main/java/noppes/npcs/controllers/data/Availability.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; @@ -10,6 +10,9 @@ import noppes.npcs.constants.EnumAvailabilityFaction; import noppes.npcs.constants.EnumAvailabilityFactionType; import noppes.npcs.constants.EnumAvailabilityQuest; import noppes.npcs.constants.EnumDayTime; +import noppes.npcs.controllers.FactionController; +import noppes.npcs.controllers.PlayerDataController; +import noppes.npcs.controllers.PlayerQuestController; import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.interfaces.handler.data.IAvailability; import noppes.npcs.scripted.interfaces.entity.IPlayer; diff --git a/src/main/java/noppes/npcs/controllers/Bank.java b/src/main/java/noppes/npcs/controllers/data/Bank.java similarity index 98% rename from src/main/java/noppes/npcs/controllers/Bank.java rename to src/main/java/noppes/npcs/controllers/data/Bank.java index 0453077d2..249ac338e 100644 --- a/src/main/java/noppes/npcs/controllers/Bank.java +++ b/src/main/java/noppes/npcs/controllers/data/Bank.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import java.util.HashMap; diff --git a/src/main/java/noppes/npcs/controllers/BankData.java b/src/main/java/noppes/npcs/controllers/data/BankData.java similarity index 98% rename from src/main/java/noppes/npcs/controllers/BankData.java rename to src/main/java/noppes/npcs/controllers/data/BankData.java index ba57ee415..a135acbc9 100644 --- a/src/main/java/noppes/npcs/controllers/BankData.java +++ b/src/main/java/noppes/npcs/controllers/data/BankData.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import java.util.HashMap; @@ -15,6 +15,7 @@ import noppes.npcs.Server; import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.containers.ContainerNPCBankInterface; +import noppes.npcs.controllers.BankController; import noppes.npcs.entity.EntityNPCInterface; public class BankData { diff --git a/src/main/java/noppes/npcs/controllers/Dialog.java b/src/main/java/noppes/npcs/controllers/data/Dialog.java similarity index 98% rename from src/main/java/noppes/npcs/controllers/Dialog.java rename to src/main/java/noppes/npcs/controllers/data/Dialog.java index 6632f8433..76ef188c1 100644 --- a/src/main/java/noppes/npcs/controllers/Dialog.java +++ b/src/main/java/noppes/npcs/controllers/data/Dialog.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import java.util.ArrayList; import java.util.HashMap; @@ -10,6 +10,8 @@ import net.minecraft.nbt.NBTTagList; import noppes.npcs.ICompatibilty; import noppes.npcs.VersionCompatibility; import noppes.npcs.constants.EnumOptionType; +import noppes.npcs.controllers.DialogController; +import noppes.npcs.controllers.QuestController; import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.interfaces.handler.data.*; diff --git a/src/main/java/noppes/npcs/controllers/DialogCategory.java b/src/main/java/noppes/npcs/controllers/data/DialogCategory.java similarity index 97% rename from src/main/java/noppes/npcs/controllers/DialogCategory.java rename to src/main/java/noppes/npcs/controllers/data/DialogCategory.java index 20c1fb0b1..a6330bae6 100644 --- a/src/main/java/noppes/npcs/controllers/DialogCategory.java +++ b/src/main/java/noppes/npcs/controllers/data/DialogCategory.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/main/java/noppes/npcs/controllers/DialogOption.java b/src/main/java/noppes/npcs/controllers/data/DialogOption.java similarity index 94% rename from src/main/java/noppes/npcs/controllers/DialogOption.java rename to src/main/java/noppes/npcs/controllers/data/DialogOption.java index 30f41cede..9bacc5367 100644 --- a/src/main/java/noppes/npcs/controllers/DialogOption.java +++ b/src/main/java/noppes/npcs/controllers/data/DialogOption.java @@ -1,8 +1,9 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.constants.EnumOptionType; +import noppes.npcs.controllers.DialogController; public class DialogOption { public int dialogId = -1; diff --git a/src/main/java/noppes/npcs/controllers/Faction.java b/src/main/java/noppes/npcs/controllers/data/Faction.java similarity index 96% rename from src/main/java/noppes/npcs/controllers/Faction.java rename to src/main/java/noppes/npcs/controllers/data/Faction.java index 03a6a44d2..be902b865 100644 --- a/src/main/java/noppes/npcs/controllers/Faction.java +++ b/src/main/java/noppes/npcs/controllers/data/Faction.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import java.util.HashSet; import java.util.Iterator; @@ -6,6 +6,8 @@ import java.util.Iterator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.NBTTags; +import noppes.npcs.controllers.FactionController; +import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.interfaces.handler.data.IFaction; @@ -72,7 +74,7 @@ public class Faction implements IFaction { } public boolean isFriendlyToPlayer(EntityPlayer player) { - PlayerFactionData data = PlayerDataController.instance.getPlayerData(player).factionData; + PlayerFactionData data = PlayerDataController.instance.getPlayerData(player).factionData; return data.getFactionPoints(id) >= friendlyPoints; } diff --git a/src/main/java/noppes/npcs/controllers/FactionOptions.java b/src/main/java/noppes/npcs/controllers/data/FactionOptions.java similarity index 93% rename from src/main/java/noppes/npcs/controllers/FactionOptions.java rename to src/main/java/noppes/npcs/controllers/data/FactionOptions.java index 2ab6351c5..cfa877d8f 100644 --- a/src/main/java/noppes/npcs/controllers/FactionOptions.java +++ b/src/main/java/noppes/npcs/controllers/data/FactionOptions.java @@ -1,8 +1,10 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentTranslation; +import noppes.npcs.controllers.FactionController; +import noppes.npcs.controllers.PlayerDataController; public class FactionOptions { @@ -45,7 +47,7 @@ public class FactionOptions { if(factionId < 0 && faction2Id < 0) return; - PlayerFactionData data = PlayerDataController.instance.getPlayerData(player).factionData; + PlayerFactionData data = PlayerDataController.instance.getPlayerData(player).factionData; if(factionId >= 0 && factionPoints > 0) addPoints(player, data, factionId, decreaseFactionPoints, factionPoints); if(faction2Id >= 0 && faction2Points> 0) diff --git a/src/main/java/noppes/npcs/controllers/Line.java b/src/main/java/noppes/npcs/controllers/data/Line.java similarity index 95% rename from src/main/java/noppes/npcs/controllers/Line.java rename to src/main/java/noppes/npcs/controllers/data/Line.java index 24b20b036..e9f5904fb 100644 --- a/src/main/java/noppes/npcs/controllers/Line.java +++ b/src/main/java/noppes/npcs/controllers/data/Line.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/main/java/noppes/npcs/controllers/Lines.java b/src/main/java/noppes/npcs/controllers/data/Lines.java similarity index 98% rename from src/main/java/noppes/npcs/controllers/Lines.java rename to src/main/java/noppes/npcs/controllers/data/Lines.java index 3a696558d..94e8c9559 100644 --- a/src/main/java/noppes/npcs/controllers/Lines.java +++ b/src/main/java/noppes/npcs/controllers/data/Lines.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/main/java/noppes/npcs/controllers/PlayerBankData.java b/src/main/java/noppes/npcs/controllers/data/PlayerBankData.java similarity index 94% rename from src/main/java/noppes/npcs/controllers/PlayerBankData.java rename to src/main/java/noppes/npcs/controllers/data/PlayerBankData.java index 73907a414..df1d40afd 100644 --- a/src/main/java/noppes/npcs/controllers/PlayerBankData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerBankData.java @@ -1,9 +1,10 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import java.util.HashMap; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import noppes.npcs.controllers.BankController; public class PlayerBankData{ public HashMap banks; diff --git a/src/main/java/noppes/npcs/controllers/PlayerData.java b/src/main/java/noppes/npcs/controllers/data/PlayerData.java similarity index 98% rename from src/main/java/noppes/npcs/controllers/PlayerData.java rename to src/main/java/noppes/npcs/controllers/data/PlayerData.java index ef1647ee7..77f779db9 100644 --- a/src/main/java/noppes/npcs/controllers/PlayerData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerData.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -9,6 +9,7 @@ import net.minecraftforge.common.IExtendedEntityProperties; import noppes.npcs.CustomNpcs; import noppes.npcs.LogWriter; import noppes.npcs.constants.EnumRoleType; +import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.data.DataSkinOverlays; diff --git a/src/main/java/noppes/npcs/controllers/PlayerDialogData.java b/src/main/java/noppes/npcs/controllers/data/PlayerDialogData.java similarity index 96% rename from src/main/java/noppes/npcs/controllers/PlayerDialogData.java rename to src/main/java/noppes/npcs/controllers/data/PlayerDialogData.java index 386c83751..93b879f46 100644 --- a/src/main/java/noppes/npcs/controllers/PlayerDialogData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerDialogData.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import java.util.HashSet; diff --git a/src/main/java/noppes/npcs/controllers/PlayerFactionData.java b/src/main/java/noppes/npcs/controllers/data/PlayerFactionData.java similarity index 96% rename from src/main/java/noppes/npcs/controllers/PlayerFactionData.java rename to src/main/java/noppes/npcs/controllers/data/PlayerFactionData.java index f98afc038..e19290fe9 100644 --- a/src/main/java/noppes/npcs/controllers/PlayerFactionData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerFactionData.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import java.util.HashMap; @@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.EventHooks; +import noppes.npcs.controllers.FactionController; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.event.FactionEvent; import noppes.npcs.scripted.interfaces.entity.IPlayer; diff --git a/src/main/java/noppes/npcs/controllers/PlayerItemGiverData.java b/src/main/java/noppes/npcs/controllers/data/PlayerItemGiverData.java similarity index 97% rename from src/main/java/noppes/npcs/controllers/PlayerItemGiverData.java rename to src/main/java/noppes/npcs/controllers/data/PlayerItemGiverData.java index d13a637cb..88bdb52f0 100644 --- a/src/main/java/noppes/npcs/controllers/PlayerItemGiverData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerItemGiverData.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import java.util.HashMap; diff --git a/src/main/java/noppes/npcs/controllers/PlayerMail.java b/src/main/java/noppes/npcs/controllers/data/PlayerMail.java similarity index 98% rename from src/main/java/noppes/npcs/controllers/PlayerMail.java rename to src/main/java/noppes/npcs/controllers/data/PlayerMail.java index 25e87804c..35677adcd 100644 --- a/src/main/java/noppes/npcs/controllers/PlayerMail.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerMail.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -6,7 +6,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.NoppesUtilServer; -import noppes.npcs.NpcMiscInventory; +import noppes.npcs.controllers.QuestController; public class PlayerMail implements IInventory{ public String subject = ""; diff --git a/src/main/java/noppes/npcs/controllers/PlayerMailData.java b/src/main/java/noppes/npcs/controllers/data/PlayerMailData.java similarity index 96% rename from src/main/java/noppes/npcs/controllers/PlayerMailData.java rename to src/main/java/noppes/npcs/controllers/data/PlayerMailData.java index eaaaad9e1..e6e9dee62 100644 --- a/src/main/java/noppes/npcs/controllers/PlayerMailData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerMailData.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import java.util.ArrayList; diff --git a/src/main/java/noppes/npcs/controllers/PlayerQuestData.java b/src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java similarity index 96% rename from src/main/java/noppes/npcs/controllers/PlayerQuestData.java rename to src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java index 4523f9ba0..4fdbd6b5b 100644 --- a/src/main/java/noppes/npcs/controllers/PlayerQuestData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import java.util.HashMap; @@ -11,6 +11,8 @@ import noppes.npcs.Server; import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumQuestCompletion; import noppes.npcs.constants.EnumQuestType; +import noppes.npcs.controllers.PlayerDataController; +import noppes.npcs.controllers.QuestController; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.quests.QuestInterface; diff --git a/src/main/java/noppes/npcs/controllers/PlayerTransportData.java b/src/main/java/noppes/npcs/controllers/data/PlayerTransportData.java similarity index 96% rename from src/main/java/noppes/npcs/controllers/PlayerTransportData.java rename to src/main/java/noppes/npcs/controllers/data/PlayerTransportData.java index 57857f798..945243474 100644 --- a/src/main/java/noppes/npcs/controllers/PlayerTransportData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerTransportData.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import java.util.HashSet; diff --git a/src/main/java/noppes/npcs/controllers/Quest.java b/src/main/java/noppes/npcs/controllers/data/Quest.java similarity index 98% rename from src/main/java/noppes/npcs/controllers/Quest.java rename to src/main/java/noppes/npcs/controllers/data/Quest.java index 1e079706b..9dcb7896c 100644 --- a/src/main/java/noppes/npcs/controllers/Quest.java +++ b/src/main/java/noppes/npcs/controllers/data/Quest.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -11,6 +11,7 @@ import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumQuestCompletion; import noppes.npcs.constants.EnumQuestRepeat; import noppes.npcs.constants.EnumQuestType; +import noppes.npcs.controllers.QuestController; import noppes.npcs.quests.QuestDialog; import noppes.npcs.quests.QuestInterface; import noppes.npcs.quests.QuestItem; diff --git a/src/main/java/noppes/npcs/controllers/QuestCategory.java b/src/main/java/noppes/npcs/controllers/data/QuestCategory.java similarity index 98% rename from src/main/java/noppes/npcs/controllers/QuestCategory.java rename to src/main/java/noppes/npcs/controllers/data/QuestCategory.java index 10da9533b..18fa87b56 100644 --- a/src/main/java/noppes/npcs/controllers/QuestCategory.java +++ b/src/main/java/noppes/npcs/controllers/data/QuestCategory.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/main/java/noppes/npcs/controllers/QuestData.java b/src/main/java/noppes/npcs/controllers/data/QuestData.java similarity index 93% rename from src/main/java/noppes/npcs/controllers/QuestData.java rename to src/main/java/noppes/npcs/controllers/data/QuestData.java index 1c51ae2ae..7db1bd6b8 100644 --- a/src/main/java/noppes/npcs/controllers/QuestData.java +++ b/src/main/java/noppes/npcs/controllers/data/QuestData.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/main/java/noppes/npcs/controllers/RecipeCarpentry.java b/src/main/java/noppes/npcs/controllers/data/RecipeCarpentry.java similarity index 98% rename from src/main/java/noppes/npcs/controllers/RecipeCarpentry.java rename to src/main/java/noppes/npcs/controllers/data/RecipeCarpentry.java index 44ae912bc..42aee003f 100644 --- a/src/main/java/noppes/npcs/controllers/RecipeCarpentry.java +++ b/src/main/java/noppes/npcs/controllers/data/RecipeCarpentry.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import java.io.IOException; import java.util.HashMap; @@ -13,6 +13,7 @@ import net.minecraft.world.World; import noppes.npcs.NBTTags; import noppes.npcs.NoppesUtilPlayer; import noppes.npcs.NoppesUtilServer; +import noppes.npcs.controllers.RecipeController; import noppes.npcs.scripted.interfaces.handler.data.IRecipe; public class RecipeCarpentry extends ShapedRecipes implements IRecipe { diff --git a/src/main/java/noppes/npcs/controllers/RecipesDefault.java b/src/main/java/noppes/npcs/controllers/data/RecipesDefault.java similarity index 99% rename from src/main/java/noppes/npcs/controllers/RecipesDefault.java rename to src/main/java/noppes/npcs/controllers/data/RecipesDefault.java index 629bbfd4e..843c1cc06 100644 --- a/src/main/java/noppes/npcs/controllers/RecipesDefault.java +++ b/src/main/java/noppes/npcs/controllers/data/RecipesDefault.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import net.minecraft.block.Block; import net.minecraft.init.Blocks; @@ -7,6 +7,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import noppes.npcs.CustomItems; import noppes.npcs.CustomNpcs; +import noppes.npcs.controllers.RecipeController; + public class RecipesDefault { public static void addRecipe(String name, Object ob, boolean isGlobal, Object... recipe){ ItemStack item; diff --git a/src/main/java/noppes/npcs/controllers/SpawnData.java b/src/main/java/noppes/npcs/controllers/data/SpawnData.java similarity index 96% rename from src/main/java/noppes/npcs/controllers/SpawnData.java rename to src/main/java/noppes/npcs/controllers/data/SpawnData.java index 113937f4a..496c11678 100644 --- a/src/main/java/noppes/npcs/controllers/SpawnData.java +++ b/src/main/java/noppes/npcs/controllers/data/SpawnData.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/noppes/npcs/controllers/TransformData.java b/src/main/java/noppes/npcs/controllers/data/TransformData.java similarity index 99% rename from src/main/java/noppes/npcs/controllers/TransformData.java rename to src/main/java/noppes/npcs/controllers/data/TransformData.java index 4a41c4e37..798a3db64 100644 --- a/src/main/java/noppes/npcs/controllers/TransformData.java +++ b/src/main/java/noppes/npcs/controllers/data/TransformData.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import java.util.Set; diff --git a/src/main/java/noppes/npcs/controllers/TransportCategory.java b/src/main/java/noppes/npcs/controllers/data/TransportCategory.java similarity index 97% rename from src/main/java/noppes/npcs/controllers/TransportCategory.java rename to src/main/java/noppes/npcs/controllers/data/TransportCategory.java index 5fe2dba9c..fdfa21f86 100644 --- a/src/main/java/noppes/npcs/controllers/TransportCategory.java +++ b/src/main/java/noppes/npcs/controllers/data/TransportCategory.java @@ -1,4 +1,4 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import java.util.HashMap; import java.util.Vector; diff --git a/src/main/java/noppes/npcs/controllers/TransportLocation.java b/src/main/java/noppes/npcs/controllers/data/TransportLocation.java similarity index 93% rename from src/main/java/noppes/npcs/controllers/TransportLocation.java rename to src/main/java/noppes/npcs/controllers/data/TransportLocation.java index ae677fd1a..fc1dcb620 100644 --- a/src/main/java/noppes/npcs/controllers/TransportLocation.java +++ b/src/main/java/noppes/npcs/controllers/data/TransportLocation.java @@ -1,7 +1,6 @@ -package noppes.npcs.controllers; +package noppes.npcs.controllers.data; import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.entity.EntityNPCInterface; public class TransportLocation { public int id = -1; diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index d576c5e8e..9646d41f7 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -62,17 +62,17 @@ import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumPotionType; import noppes.npcs.constants.EnumRoleType; import noppes.npcs.constants.EnumStandingType; -import noppes.npcs.controllers.Dialog; -import noppes.npcs.controllers.DialogOption; -import noppes.npcs.controllers.Faction; +import noppes.npcs.controllers.data.Dialog; +import noppes.npcs.controllers.data.DialogOption; +import noppes.npcs.controllers.data.Faction; import noppes.npcs.controllers.FactionController; -import noppes.npcs.controllers.Line; +import noppes.npcs.controllers.data.Line; import noppes.npcs.controllers.LinkedNpcController; import noppes.npcs.controllers.LinkedNpcController.LinkedData; import noppes.npcs.controllers.PlayerDataController; -import noppes.npcs.controllers.PlayerQuestData; -import noppes.npcs.controllers.QuestData; -import noppes.npcs.controllers.TransformData; +import noppes.npcs.controllers.data.PlayerQuestData; +import noppes.npcs.controllers.data.QuestData; +import noppes.npcs.controllers.data.TransformData; import noppes.npcs.entity.data.DataTimers; import noppes.npcs.roles.JobBard; import noppes.npcs.roles.JobFollower; @@ -80,7 +80,6 @@ import noppes.npcs.roles.JobInterface; import noppes.npcs.roles.RoleCompanion; import noppes.npcs.roles.RoleFollower; import noppes.npcs.roles.RoleInterface; -import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.entity.ScriptNpc; import noppes.npcs.scripted.event.ScriptEventAttack; import noppes.npcs.scripted.event.ScriptEventDamaged; diff --git a/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java b/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java index 819159c9f..05f3e416a 100644 --- a/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java +++ b/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java @@ -4,7 +4,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.Server; import noppes.npcs.constants.EnumPacketClient; -import noppes.npcs.controllers.PlayerData; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.SkinOverlay; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.interfaces.ISkinOverlay; diff --git a/src/main/java/noppes/npcs/entity/data/DataTimers.java b/src/main/java/noppes/npcs/entity/data/DataTimers.java index a8da1fb29..228e7a02b 100644 --- a/src/main/java/noppes/npcs/entity/data/DataTimers.java +++ b/src/main/java/noppes/npcs/entity/data/DataTimers.java @@ -14,7 +14,7 @@ import net.minecraft.nbt.NBTTagList; import noppes.npcs.EventHooks; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.interfaces.ITimers; -import noppes.npcs.controllers.PlayerData; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.scripted.CustomNPCsException; public class DataTimers implements ITimers { diff --git a/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java b/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java index 8a05e130e..416bb62a3 100644 --- a/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java +++ b/src/main/java/noppes/npcs/items/ItemSoulstoneFilled.java @@ -1,12 +1,9 @@ package noppes.npcs.items; -import java.text.DateFormat; -import java.util.Date; import java.util.List; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -15,9 +12,8 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.World; import noppes.npcs.constants.EnumRoleType; -import noppes.npcs.controllers.PlayerData; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.PlayerDataController; -import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleCompanion; import noppes.npcs.roles.RoleFollower; diff --git a/src/main/java/noppes/npcs/quests/QuestDialog.java b/src/main/java/noppes/npcs/quests/QuestDialog.java index aee27eabe..b4357d233 100644 --- a/src/main/java/noppes/npcs/quests/QuestDialog.java +++ b/src/main/java/noppes/npcs/quests/QuestDialog.java @@ -9,9 +9,9 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.NBTTags; import noppes.npcs.constants.EnumQuestType; -import noppes.npcs.controllers.Dialog; +import noppes.npcs.controllers.data.Dialog; import noppes.npcs.controllers.DialogController; -import noppes.npcs.controllers.PlayerData; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.interfaces.handler.data.IQuestDialog; diff --git a/src/main/java/noppes/npcs/quests/QuestInterface.java b/src/main/java/noppes/npcs/quests/QuestInterface.java index b385471fc..05188dd2e 100644 --- a/src/main/java/noppes/npcs/quests/QuestInterface.java +++ b/src/main/java/noppes/npcs/quests/QuestInterface.java @@ -4,7 +4,7 @@ import java.util.Vector; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.controllers.PlayerData; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.scripted.interfaces.handler.data.IQuestInterface; import noppes.npcs.scripted.interfaces.handler.data.IQuestObjective; diff --git a/src/main/java/noppes/npcs/quests/QuestItem.java b/src/main/java/noppes/npcs/quests/QuestItem.java index dc6be0aa6..1bd8bd7c1 100644 --- a/src/main/java/noppes/npcs/quests/QuestItem.java +++ b/src/main/java/noppes/npcs/quests/QuestItem.java @@ -8,7 +8,7 @@ import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.NoppesUtilPlayer; import noppes.npcs.NoppesUtilServer; import noppes.npcs.NpcMiscInventory; -import noppes.npcs.controllers.PlayerData; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.interfaces.handler.data.IQuestItem; import noppes.npcs.scripted.interfaces.handler.data.IQuestObjective; diff --git a/src/main/java/noppes/npcs/quests/QuestKill.java b/src/main/java/noppes/npcs/quests/QuestKill.java index 08be78a53..53542f141 100644 --- a/src/main/java/noppes/npcs/quests/QuestKill.java +++ b/src/main/java/noppes/npcs/quests/QuestKill.java @@ -6,10 +6,10 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.NBTTags; import noppes.npcs.constants.EnumQuestType; -import noppes.npcs.controllers.PlayerData; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.PlayerDataController; -import noppes.npcs.controllers.PlayerQuestData; -import noppes.npcs.controllers.QuestData; +import noppes.npcs.controllers.data.PlayerQuestData; +import noppes.npcs.controllers.data.QuestData; import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.interfaces.handler.data.IQuestKill; import noppes.npcs.scripted.interfaces.handler.data.IQuestObjective; diff --git a/src/main/java/noppes/npcs/quests/QuestLocation.java b/src/main/java/noppes/npcs/quests/QuestLocation.java index 5b9f7d84c..16d4bbdb4 100644 --- a/src/main/java/noppes/npcs/quests/QuestLocation.java +++ b/src/main/java/noppes/npcs/quests/QuestLocation.java @@ -8,10 +8,10 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import noppes.npcs.constants.EnumQuestType; -import noppes.npcs.controllers.PlayerData; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.PlayerDataController; -import noppes.npcs.controllers.PlayerQuestData; -import noppes.npcs.controllers.QuestData; +import noppes.npcs.controllers.data.PlayerQuestData; +import noppes.npcs.controllers.data.QuestData; import noppes.npcs.scripted.CustomNPCsException; import noppes.npcs.scripted.interfaces.handler.data.IQuestLocation; import noppes.npcs.scripted.interfaces.handler.data.IQuestObjective; diff --git a/src/main/java/noppes/npcs/roles/JobConversation.java b/src/main/java/noppes/npcs/roles/JobConversation.java index 6fe448ae2..56a99ea7c 100644 --- a/src/main/java/noppes/npcs/roles/JobConversation.java +++ b/src/main/java/noppes/npcs/roles/JobConversation.java @@ -7,10 +7,10 @@ import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import noppes.npcs.controllers.Availability; -import noppes.npcs.controllers.Line; +import noppes.npcs.controllers.data.Availability; +import noppes.npcs.controllers.data.Line; import noppes.npcs.controllers.PlayerQuestController; -import noppes.npcs.controllers.Quest; +import noppes.npcs.controllers.data.Quest; import noppes.npcs.controllers.QuestController; import noppes.npcs.entity.EntityNPCInterface; diff --git a/src/main/java/noppes/npcs/roles/JobItemGiver.java b/src/main/java/noppes/npcs/roles/JobItemGiver.java index 7d26f30aa..80c3319fb 100644 --- a/src/main/java/noppes/npcs/roles/JobItemGiver.java +++ b/src/main/java/noppes/npcs/roles/JobItemGiver.java @@ -12,11 +12,11 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.NBTTags; import noppes.npcs.NpcMiscInventory; -import noppes.npcs.controllers.Availability; +import noppes.npcs.controllers.data.Availability; import noppes.npcs.controllers.GlobalDataController; -import noppes.npcs.controllers.Line; +import noppes.npcs.controllers.data.Line; import noppes.npcs.controllers.PlayerDataController; -import noppes.npcs.controllers.PlayerItemGiverData; +import noppes.npcs.controllers.data.PlayerItemGiverData; import noppes.npcs.entity.EntityNPCInterface; public class JobItemGiver extends JobInterface{ diff --git a/src/main/java/noppes/npcs/roles/RoleBank.java b/src/main/java/noppes/npcs/roles/RoleBank.java index 770b33cb9..13d939d65 100644 --- a/src/main/java/noppes/npcs/roles/RoleBank.java +++ b/src/main/java/noppes/npcs/roles/RoleBank.java @@ -2,9 +2,9 @@ package noppes.npcs.roles; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.controllers.Bank; +import noppes.npcs.controllers.data.Bank; import noppes.npcs.controllers.BankController; -import noppes.npcs.controllers.BankData; +import noppes.npcs.controllers.data.BankData; import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.entity.EntityNPCInterface; diff --git a/src/main/java/noppes/npcs/roles/RoleCompanion.java b/src/main/java/noppes/npcs/roles/RoleCompanion.java index 853745bc1..56f41f925 100644 --- a/src/main/java/noppes/npcs/roles/RoleCompanion.java +++ b/src/main/java/noppes/npcs/roles/RoleCompanion.java @@ -1,7 +1,6 @@ package noppes.npcs.roles; import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -16,8 +15,6 @@ import cpw.mods.fml.common.ObfuscationReflectionHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; -import net.minecraft.entity.ai.attributes.BaseAttributeMap; -import net.minecraft.entity.ai.attributes.IAttributeInstance; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -33,7 +30,6 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; -import noppes.npcs.CustomNpcs; import noppes.npcs.NoppesUtilServer; import noppes.npcs.NpcMiscInventory; import noppes.npcs.constants.EnumAnimation; @@ -41,7 +37,7 @@ import noppes.npcs.constants.EnumCompanionJobs; import noppes.npcs.constants.EnumCompanionStage; import noppes.npcs.constants.EnumCompanionTalent; import noppes.npcs.constants.EnumGuiType; -import noppes.npcs.controllers.PlayerData; +import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; diff --git a/src/main/java/noppes/npcs/roles/RoleTransporter.java b/src/main/java/noppes/npcs/roles/RoleTransporter.java index 79a1f83fe..d6b61b391 100644 --- a/src/main/java/noppes/npcs/roles/RoleTransporter.java +++ b/src/main/java/noppes/npcs/roles/RoleTransporter.java @@ -3,17 +3,14 @@ package noppes.npcs.roles; import java.util.List; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentTranslation; import noppes.npcs.NoppesUtilServer; -import noppes.npcs.Server; import noppes.npcs.constants.EnumGuiType; -import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.controllers.PlayerDataController; -import noppes.npcs.controllers.PlayerTransportData; +import noppes.npcs.controllers.data.PlayerTransportData; import noppes.npcs.controllers.TransportController; -import noppes.npcs.controllers.TransportLocation; +import noppes.npcs.controllers.data.TransportLocation; import noppes.npcs.entity.EntityNPCInterface; public class RoleTransporter extends RoleInterface{ diff --git a/src/main/java/noppes/npcs/scripted/ScriptFaction.java b/src/main/java/noppes/npcs/scripted/ScriptFaction.java index 8fdcd6fba..91d633376 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptFaction.java +++ b/src/main/java/noppes/npcs/scripted/ScriptFaction.java @@ -1,7 +1,7 @@ package noppes.npcs.scripted; import net.minecraft.entity.player.EntityPlayer; -import noppes.npcs.controllers.Faction; +import noppes.npcs.controllers.data.Faction; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import noppes.npcs.scripted.interfaces.entity.IPlayer; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index a2c4a846b..47fbf922c 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -4,7 +4,7 @@ import net.minecraft.entity.player.EntityPlayer; import noppes.npcs.CustomNpcs; import noppes.npcs.NoppesUtilServer; import noppes.npcs.constants.*; -import noppes.npcs.controllers.Line; +import noppes.npcs.controllers.data.Line; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.ScriptFaction; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index e199e966d..7ac0e7d42 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -5,7 +5,6 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; import net.minecraft.stats.Achievement; import net.minecraft.stats.StatBase; import net.minecraft.stats.StatList; @@ -17,6 +16,7 @@ import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumQuestType; import noppes.npcs.containers.ContainerCustomGui; import noppes.npcs.controllers.*; +import noppes.npcs.controllers.data.*; import noppes.npcs.entity.EntityDialogNpc; import noppes.npcs.scripted.*; import noppes.npcs.scripted.constants.EntityType; @@ -134,7 +134,7 @@ public class ScriptPlayer extends ScriptLivingBase PlayerData data = PlayerDataController.instance.getPlayerData(player); if(data.questData.activeQuests.containsKey(id)) return; - QuestData questdata = new QuestData(quest); + QuestData questdata = new QuestData(quest); data.questData.activeQuests.put(id, questdata); Server.sendData((EntityPlayerMP)player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title); Server.sendData((EntityPlayerMP)player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title); diff --git a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java index 1fe400811..e1a5c69f0 100644 --- a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java @@ -10,8 +10,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.DamageSource; -import noppes.npcs.controllers.Dialog; -import noppes.npcs.controllers.ScriptController; +import noppes.npcs.controllers.data.Dialog; import noppes.npcs.scripted.interfaces.*; import noppes.npcs.scripted.interfaces.entity.ICustomNpc; import noppes.npcs.scripted.interfaces.entity.IEntity; diff --git a/src/main/java/noppes/npcs/scripted/event/ScriptEventDialog.java b/src/main/java/noppes/npcs/scripted/event/ScriptEventDialog.java index 436cb7027..f546ce429 100644 --- a/src/main/java/noppes/npcs/scripted/event/ScriptEventDialog.java +++ b/src/main/java/noppes/npcs/scripted/event/ScriptEventDialog.java @@ -1,8 +1,7 @@ package noppes.npcs.scripted.event; import net.minecraft.entity.player.EntityPlayer; -import noppes.npcs.controllers.Dialog; -import noppes.npcs.controllers.ScriptController; +import noppes.npcs.controllers.data.Dialog; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.entity.IPlayer; From 95bc4bf42d815c4fb137d5e7000e93f710542a7c Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 24 May 2022 01:08:23 -0500 Subject: [PATCH 72/75] Renamed TransformData to DataTransform. --- .../noppes/npcs/client/gui/advanced/GuiNPCNightSetup.java | 4 ++-- .../data/{TransformData.java => DataTransform.java} | 4 ++-- src/main/java/noppes/npcs/entity/EntityNPCInterface.java | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) rename src/main/java/noppes/npcs/controllers/data/{TransformData.java => DataTransform.java} (99%) diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCNightSetup.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCNightSetup.java index 75b14dce9..a501d6b2b 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCNightSetup.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCNightSetup.java @@ -8,12 +8,12 @@ import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.IGuiData; import noppes.npcs.constants.EnumPacketServer; -import noppes.npcs.controllers.data.TransformData; +import noppes.npcs.controllers.data.DataTransform; import noppes.npcs.entity.EntityNPCInterface; public class GuiNPCNightSetup extends GuiNPCInterface2 implements IGuiData { - private TransformData data; + private DataTransform data; public GuiNPCNightSetup(EntityNPCInterface npc) { diff --git a/src/main/java/noppes/npcs/controllers/data/TransformData.java b/src/main/java/noppes/npcs/controllers/data/DataTransform.java similarity index 99% rename from src/main/java/noppes/npcs/controllers/data/TransformData.java rename to src/main/java/noppes/npcs/controllers/data/DataTransform.java index 798a3db64..363e9aed7 100644 --- a/src/main/java/noppes/npcs/controllers/data/TransformData.java +++ b/src/main/java/noppes/npcs/controllers/data/DataTransform.java @@ -16,7 +16,7 @@ import noppes.npcs.constants.EnumRoleType; import noppes.npcs.entity.EntityCustomNpc; import noppes.npcs.entity.EntityNPCInterface; -public class TransformData { +public class DataTransform { public NBTTagCompound display; public NBTTagCompound ai; public NBTTagCompound advanced; @@ -31,7 +31,7 @@ public class TransformData { public boolean editingModus = false; - public TransformData(EntityNPCInterface npc){ + public DataTransform(EntityNPCInterface npc){ this.npc = npc; } diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 9646d41f7..f50c326cb 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -72,7 +72,7 @@ import noppes.npcs.controllers.LinkedNpcController.LinkedData; import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.data.PlayerQuestData; import noppes.npcs.controllers.data.QuestData; -import noppes.npcs.controllers.data.TransformData; +import noppes.npcs.controllers.data.DataTransform; import noppes.npcs.entity.data.DataTimers; import noppes.npcs.roles.JobBard; import noppes.npcs.roles.JobFollower; @@ -101,7 +101,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti public DataAdvanced advanced; public DataInventory inventory; public DataScript script; - public TransformData transform; + public DataTransform transform; public DataTimers timers; public String linkedName = ""; @@ -182,7 +182,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti ai = new DataAI(this); advanced = new DataAdvanced(this); inventory = new DataInventory(this); - transform = new TransformData(this); + transform = new DataTransform(this); script = new DataScript(this); timers = new DataTimers(this); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage); From 38e960d47509a1c8f0c047ee462ac6139c49a416 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 24 May 2022 19:30:24 -0500 Subject: [PATCH 73/75] x32 textures now compatible with x64 models. --- .../client/renderer/RenderNPCInterface.java | 75 ++++++++++++++----- 1 file changed, 55 insertions(+), 20 deletions(-) diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java index 08760d018..74f428de9 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCInterface.java @@ -1,6 +1,9 @@ package noppes.npcs.client.renderer; +import java.awt.image.BufferedImage; import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.security.MessageDigest; import java.util.Map; @@ -13,6 +16,7 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.texture.ITextureObject; import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.resources.IResource; import net.minecraft.client.resources.SkinManager; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; @@ -32,6 +36,8 @@ import org.lwjgl.opengl.GL11; import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; +import javax.imageio.ImageIO; + public class RenderNPCInterface extends RenderLiving{ public static long LastTextureTick = 0; @@ -292,51 +298,80 @@ public class RenderNPCInterface extends RenderLiving{ public ResourceLocation getEntityTexture(Entity entity) { EntityNPCInterface npc = (EntityNPCInterface) entity; - if(npc.textureLocation == null){ - if(npc.display.skinType == 0) { + if (npc.textureLocation == null) { + if (npc.display.skinType == 0) { if (!(npc.display.texture).equals("")) { - npc.textureLocation = new ResourceLocation(npc.display.texture); + //npc.textureLocation = new ResourceLocation(npc.display.texture); + try { + npc.textureLocation = adjustLocalTexture(npc, new ResourceLocation(npc.display.texture)); + } catch (IOException ignored) {} } - } - else if(LastTextureTick < 5){ //fixes request flood somewhat + } else if(LastTextureTick < 5) { //fixes request flood somewhat return AbstractClientPlayer.locationStevePng; - } - else if(npc.display.skinType == 1 && npc.display.playerProfile != null){ + } else if(npc.display.skinType == 1 && npc.display.playerProfile != null) { Minecraft minecraft = Minecraft.getMinecraft(); Map map = minecraft.func_152342_ad().func_152788_a(npc.display.playerProfile); if (map.containsKey(Type.SKIN)){ npc.textureLocation = minecraft.func_152342_ad().func_152792_a((MinecraftProfileTexture)map.get(Type.SKIN), Type.SKIN); } LastTextureTick = 0; - } - else if(npc.display.skinType == 2 || npc.display.skinType == 3){ - try{ + } else if (npc.display.skinType == 2 || npc.display.skinType == 3) { + try { MessageDigest digest = MessageDigest.getInstance("MD5"); byte[] hash = digest.digest(npc.display.url.getBytes("UTF-8")); StringBuilder sb = new StringBuilder(2*hash.length); - for(byte b : hash){ + for (byte b : hash) { sb.append(String.format("%02x", b&0xff)); } - if(npc.display.skinType == 2){ + if (npc.display.skinType == 2) { npc.textureLocation = new ResourceLocation("skins/" + sb.toString()); loadSkin(null, npc.textureLocation, npc.display.url, false); - } - else{ + } else { npc.textureLocation = new ResourceLocation("skins64/" + sb.toString()); loadSkin(null, npc.textureLocation, npc.display.url, true); } LastTextureTick = 0; - } - catch(Exception ex){ - - } + } catch(Exception ignored){} + } else { + return AbstractClientPlayer.locationStevePng; } } - if(npc.textureLocation == null) - return AbstractClientPlayer.locationStevePng; return npc.textureLocation; } + private ResourceLocation adjustLocalTexture(EntityNPCInterface npc, ResourceLocation location) throws IOException { + if (npc.display.modelType != 0) { + return location; + } + + InputStream inputstream = null; + + try { + IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(location); + inputstream = iresource.getInputStream(); + + BufferedImage bufferedimage = ImageIO.read(inputstream); + + int totalWidth = bufferedimage.getWidth(); + int totalHeight = bufferedimage.getHeight(); + + if (totalHeight > 32) { + bufferedimage = bufferedimage.getSubimage(0, 0, totalWidth, 32); + + TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); + ImageDownloadAlt object = new ImageDownloadAlt(null, npc.display.texture, SkinManager.field_152793_a, new ImageBufferDownloadAlt(false)); + object.setBufferedImage(bufferedimage); + texturemanager.loadTexture(location, object); + } + + return location; + } finally { + if (inputstream != null) { + inputstream.close(); + } + } + } + // 64x64 Skin is True private void loadSkin(File file, ResourceLocation resource, String par1Str, boolean version){ TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); From 2895f7a76a65270f69e3251d27214b8852dd8809 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Thu, 26 May 2022 01:46:38 -0500 Subject: [PATCH 74/75] Removed overridden getDimension() function, and an unused HashMap for skin overlays from ScriptPlayer. --- src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index 7ac0e7d42..1677300c8 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -36,7 +36,6 @@ import noppes.npcs.util.ValueUtil; import java.util.*; public class ScriptPlayer extends ScriptLivingBase implements IPlayer { - public HashMap skinOverlays = new HashMap<>(); public T player; private PlayerData data; @@ -95,10 +94,6 @@ public class ScriptPlayer extends ScriptLivingBase player.getFoodStats().addStats(0,saturation-prevSaturation); } - public int getDimension(){ - return player.dimension; - } - public boolean hasFinishedQuest(int id){ PlayerQuestData data = PlayerDataController.instance.getPlayerData(player).questData; From 301e113be2f37bd82aeac0d9f820168b21fabefe Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Fri, 27 May 2022 14:32:24 -0500 Subject: [PATCH 75/75] Added quest tracking, need to add objectives list and turn in info too. --- src/main/java/noppes/npcs/CustomNpcs.java | 14 + .../java/noppes/npcs/PacketHandlerServer.java | 48 +- src/main/java/noppes/npcs/QuestLogData.java | 13 +- .../noppes/npcs/ScriptPlayerEventHandler.java | 12 + src/main/java/noppes/npcs/client/Client.java | 3 + .../npcs/client/ClientEventHandler.java | 5 + .../npcs/client/PacketHandlerClient.java | 14 +- .../npcs/client/gui/OverlayQuestTracking.java | 590 ++++++++++++++++++ .../npcs/client/gui/player/GuiQuestLog.java | 74 ++- .../client/renderer/RenderCNPCPlayer.java | 4 +- .../npcs/constants/EnumPacketClient.java | 7 +- .../npcs/constants/EnumPacketServer.java | 4 +- .../npcs/controllers/CustomGuiController.java | 4 +- .../controllers/data/PlayerQuestData.java | 12 +- .../npcs/scripted/entity/ScriptPlayer.java | 2 +- 15 files changed, 751 insertions(+), 55 deletions(-) create mode 100644 src/main/java/noppes/npcs/client/gui/OverlayQuestTracking.java diff --git a/src/main/java/noppes/npcs/CustomNpcs.java b/src/main/java/noppes/npcs/CustomNpcs.java index e7350179a..e67ae182c 100644 --- a/src/main/java/noppes/npcs/CustomNpcs.java +++ b/src/main/java/noppes/npcs/CustomNpcs.java @@ -63,6 +63,15 @@ public class CustomNpcs { @ConfigProp(info = "The amount of time that passes before a player's quests are checked for completion in seconds.") public static int PlayerQuestCheck = 300; + @ConfigProp(info = "Client sided! Determines where tracking quest info shows up on the screen based on a number from 0 to 8.") + public static int TrackingInfoAlignment = 5; + + @ConfigProp(info = "Client sided! Offsets the tracking info GUI by this amount in the X direction.") + public static int TrackingInfoX = 0; + + @ConfigProp(info = "Client sided! Offsets the tracking info GUI by this amount in the Y direction.") + public static int TrackingInfoY = 0; + @ConfigProp public static boolean InventoryGuiEnabled = true; @@ -165,6 +174,11 @@ public class CustomNpcs { if(PlayerQuestCheck < 1) PlayerQuestCheck = 1; + if (TrackingInfoAlignment < 0) + TrackingInfoAlignment = 0; + if (TrackingInfoAlignment > 8) + TrackingInfoAlignment = 8; + EnchantInterface.load(); CustomItems.load(); diff --git a/src/main/java/noppes/npcs/PacketHandlerServer.java b/src/main/java/noppes/npcs/PacketHandlerServer.java index f15693742..0a030410c 100644 --- a/src/main/java/noppes/npcs/PacketHandlerServer.java +++ b/src/main/java/noppes/npcs/PacketHandlerServer.java @@ -72,19 +72,19 @@ public class PacketHandlerServer{ EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player); - if(type == EnumPacketServer.IsGuiOpen) { + if (type == EnumPacketServer.IsGuiOpen) { isGuiOpenPacket(buffer, player); return; - } else if (type == EnumPacketServer.CustomGuiButton && player.openContainer instanceof ContainerCustomGui) { - ((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer)); - EventHooks.onCustomGuiButton((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt()); + } else if (type == EnumPacketServer.CustomGuiButton && player.openContainer instanceof ContainerCustomGui) { + ((ContainerCustomGui) player.openContainer).customGui.fromNBT(Server.readNBT(buffer)); + EventHooks.onCustomGuiButton((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt()); return; } else if (type == EnumPacketServer.CustomGuiSlotChange && player.openContainer instanceof ContainerCustomGui) { - ((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer)); - EventHooks.onCustomGuiSlot((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui)player.openContainer).customGui, buffer.readInt()); + ((ContainerCustomGui) player.openContainer).customGui.fromNBT(Server.readNBT(buffer)); + EventHooks.onCustomGuiSlot((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt()); return; - } else if(type == EnumPacketServer.CustomGuiUnfocused && player.openContainer instanceof ContainerCustomGui) { - ((ContainerCustomGui)player.openContainer).customGui.fromNBT(Server.readNBT(buffer)); + } else if (type == EnumPacketServer.CustomGuiUnfocused && player.openContainer instanceof ContainerCustomGui) { + ((ContainerCustomGui) player.openContainer).customGui.fromNBT(Server.readNBT(buffer)); EventHooks.onCustomGuiUnfocused((IPlayer) NpcAPI.Instance().getIEntity(player), ((ContainerCustomGui) player.openContainer).customGui, buffer.readInt()); return; } else if (type == EnumPacketServer.CustomGuiScrollClick && player.openContainer instanceof ContainerCustomGui) { @@ -94,6 +94,9 @@ public class PacketHandlerServer{ } else if (type == EnumPacketServer.CustomGuiClose) { EventHooks.onCustomGuiClose((IPlayer) NpcAPI.Instance().getIEntity(player), (new ScriptGui()).fromNBT(Server.readNBT(buffer))); return; + } else if (type == EnumPacketServer.UpdateTrackedQuest) { + updateTrackedQuest(buffer, player); + return; } if(type.needsNpc && npc == null){ @@ -126,7 +129,7 @@ public class PacketHandlerServer{ itemScriptPackets(type, buffer, player); else if (type == EnumPacketServer.ScriptGlobalGuiDataGet || type == EnumPacketServer.ScriptGlobalGuiDataSave) getScriptsEnabled(type, buffer, player); - else if (type == EnumPacketServer.SERVER_UPDATE_SKIN_OVERLAYS) + else if (type == EnumPacketServer.ServerUpdateSkinOverlays) updateSkinOverlays(player); else if (item.getItem() == CustomItems.scripter) scriptPackets(type, buffer, player, npc); @@ -139,6 +142,33 @@ public class PacketHandlerServer{ } } + private void updateTrackedQuest(ByteBuf buffer, EntityPlayerMP player) { + String trackedQuestString = Server.readString(buffer); + if (trackedQuestString != null && trackedQuestString.contains(":")) { + String[] splitString = trackedQuestString.split(":"); + String categoryName = splitString[0]; + String questName = splitString[1]; + + for (QuestCategory category : QuestController.instance.categories.values()) { + if (category.title.equals(categoryName)) { + for (Quest quest : category.quests.values()) { + if (quest.title.equals(questName)) { + PlayerDataController.instance.getPlayerData(player).questData.trackedQuest = quest; + NBTTagCompound compound = new NBTTagCompound(); + compound.setTag("Quest",quest.writeToNBT(new NBTTagCompound())); + compound.setString("CategoryName", quest.getCategory().getName()); + Server.sendData(player, EnumPacketClient.OVERLAY_QUEST_TRACKING, compound); + return; + } + } + } + } + } + + PlayerDataController.instance.getPlayerData(player).questData.trackedQuest = null; + Server.sendData(player, EnumPacketClient.OVERLAY_QUEST_TRACKING); + } + private void isGuiOpenPacket(ByteBuf buffer, EntityPlayerMP player) throws IOException { NoppesUtilServer.isGUIOpen(buffer, player); } diff --git a/src/main/java/noppes/npcs/QuestLogData.java b/src/main/java/noppes/npcs/QuestLogData.java index 423da0757..89c45fa1c 100644 --- a/src/main/java/noppes/npcs/QuestLogData.java +++ b/src/main/java/noppes/npcs/QuestLogData.java @@ -12,6 +12,7 @@ import noppes.npcs.controllers.PlayerQuestController; import noppes.npcs.controllers.data.Quest; public class QuestLogData { + public String trackedQuestKey = ""; public HashMap> categories = new HashMap>(); public String selectedQuest = ""; public String selectedCategory = ""; @@ -25,6 +26,7 @@ public class QuestLogData { compound.setTag("Logs", NBTTags.nbtStringStringMap(questText)); compound.setTag("Status", NBTTags.nbtVectorMap(questStatus)); compound.setTag("QuestFinisher", NBTTags.nbtStringStringMap(finish)); + compound.setString("TrackedQuestID", trackedQuestKey); return compound; } @@ -33,11 +35,12 @@ public class QuestLogData { questText = NBTTags.getStringStringMap(compound.getTagList("Logs", 10)); questStatus = NBTTags.getVectorMap(compound.getTagList("Status", 10)); finish = NBTTags.getStringStringMap(compound.getTagList("QuestFinisher", 10)); - + trackedQuestKey = compound.getString("TrackedQuestID"); } public void setData(EntityPlayer player){ PlayerData playerData = PlayerDataController.instance.getPlayerData(player); - for(Quest quest : PlayerQuestController.getActiveQuests(player)) + + for(Quest quest : PlayerQuestController.getActiveQuests(player)) { String category = quest.category.title; if(!categories.containsKey(category)) @@ -50,6 +53,12 @@ public class QuestLogData { questStatus.put(category + ":" + quest.title, quest.questInterface.getQuestLogStatus(player)); if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(playerData)) finish.put(category + ":" + quest.title, quest.completerNpc); + + if (playerData.questData.trackedQuest != null) { + if (quest.id == playerData.questData.trackedQuest.getId()) { + trackedQuestKey = category + ":" + quest.title; + } + } } } diff --git a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java index aa6b73239..3bfed30b9 100644 --- a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java @@ -12,7 +12,9 @@ import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.relauncher.Side; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.ContainerPlayer; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; @@ -26,11 +28,13 @@ import net.minecraftforge.event.entity.living.LivingFallEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.player.*; import net.minecraftforge.event.world.*; +import noppes.npcs.constants.EnumPacketClient; import noppes.npcs.constants.EnumQuestType; import noppes.npcs.controllers.*; import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.PlayerDataScript; import noppes.npcs.controllers.data.PlayerQuestData; +import noppes.npcs.controllers.data.Quest; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.interfaces.entity.IPlayer; @@ -428,6 +432,14 @@ public class ScriptPlayerEventHandler { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player); EventHooks.onPlayerLogin(handler, scriptPlayer); + + Quest quest = (Quest) PlayerDataController.instance.getPlayerData(event.player).questData.trackedQuest; + if (quest != null) { + NBTTagCompound compound = new NBTTagCompound(); + compound.setTag("Quest",quest.writeToNBT(new NBTTagCompound())); + compound.setString("CategoryName", quest.getCategory().getName()); + Server.sendData((EntityPlayerMP) event.player, EnumPacketClient.OVERLAY_QUEST_TRACKING, compound); + } } } diff --git a/src/main/java/noppes/npcs/client/Client.java b/src/main/java/noppes/npcs/client/Client.java index 248885aa7..04d95c615 100644 --- a/src/main/java/noppes/npcs/client/Client.java +++ b/src/main/java/noppes/npcs/client/Client.java @@ -7,14 +7,17 @@ import java.io.IOException; import java.util.HashMap; import java.util.UUID; +import net.minecraft.client.Minecraft; import noppes.npcs.CustomNpcs; import noppes.npcs.Server; +import noppes.npcs.client.gui.OverlayQuestTracking; import noppes.npcs.client.gui.customoverlay.OverlayCustom; import noppes.npcs.constants.EnumPacketServer; import cpw.mods.fml.common.network.internal.FMLProxyPacket; import noppes.npcs.controllers.data.SkinOverlay; public class Client { + public static OverlayQuestTracking questTrackingOverlay = null; public static HashMap customOverlays = new HashMap<>(); public static HashMap> skinOverlays = new HashMap<>(); diff --git a/src/main/java/noppes/npcs/client/ClientEventHandler.java b/src/main/java/noppes/npcs/client/ClientEventHandler.java index a1e28d3bc..a25950633 100644 --- a/src/main/java/noppes/npcs/client/ClientEventHandler.java +++ b/src/main/java/noppes/npcs/client/ClientEventHandler.java @@ -6,6 +6,7 @@ import net.minecraft.client.Minecraft; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderHandEvent; import net.minecraftforge.client.event.RenderPlayerEvent; +import noppes.npcs.client.gui.OverlayQuestTracking; import noppes.npcs.client.gui.customoverlay.OverlayCustom; import noppes.npcs.client.renderer.RenderCNPCPlayer; import org.lwjgl.opengl.GL11; @@ -19,6 +20,10 @@ public class ClientEventHandler { for (OverlayCustom overlayCustom : Client.customOverlays.values()) { overlayCustom.renderGameOverlay(event.partialTicks); } + + if (Client.questTrackingOverlay != null) { + Client.questTrackingOverlay.renderGameOverlay(event.partialTicks); + } } } diff --git a/src/main/java/noppes/npcs/client/PacketHandlerClient.java b/src/main/java/noppes/npcs/client/PacketHandlerClient.java index 023dba9b7..be0456f18 100644 --- a/src/main/java/noppes/npcs/client/PacketHandlerClient.java +++ b/src/main/java/noppes/npcs/client/PacketHandlerClient.java @@ -26,6 +26,7 @@ import noppes.npcs.ServerEventsHandler; import noppes.npcs.client.ClientProxy.FontContainer; import noppes.npcs.client.controllers.MusicController; import noppes.npcs.client.gui.GuiNpcMobSpawnerAdd; +import noppes.npcs.client.gui.OverlayQuestTracking; import noppes.npcs.client.gui.customoverlay.OverlayCustom; import noppes.npcs.client.gui.player.GuiBook; import noppes.npcs.client.gui.util.GuiContainerNPCInterface; @@ -260,16 +261,25 @@ public class PacketHandlerClient extends PacketHandlerServer{ NoppesUtil.isGUIOpen(isGUIOpen); } - else if(type == EnumPacketClient.OVERLAY_DATA){ + else if(type == EnumPacketClient.SCRIPT_OVERLAY_DATA){ OverlayCustom overlayCustom = new OverlayCustom(Minecraft.getMinecraft()); overlayCustom.setOverlayData(Server.readNBT(buffer)); Client.customOverlays.put(overlayCustom.overlay.getID(),overlayCustom); } - else if(type == EnumPacketClient.OVERLAY_CLOSE){ + else if(type == EnumPacketClient.SCRIPT_OVERLAY_CLOSE){ int id = buffer.readInt(); Client.customOverlays.remove(id); } + else if(type == EnumPacketClient.OVERLAY_QUEST_TRACKING){ + try { + NBTTagCompound compound = Server.readNBT(buffer); + Client.questTrackingOverlay = new OverlayQuestTracking(Minecraft.getMinecraft()); + Client.questTrackingOverlay.setOverlayData(compound); + } catch (IOException e) { + Client.questTrackingOverlay = null; + } + } else if(type == EnumPacketClient.SWING_PLAYER_ARM){ Minecraft.getMinecraft().thePlayer.swingItem(); } diff --git a/src/main/java/noppes/npcs/client/gui/OverlayQuestTracking.java b/src/main/java/noppes/npcs/client/gui/OverlayQuestTracking.java new file mode 100644 index 000000000..ef3f2cd25 --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/OverlayQuestTracking.java @@ -0,0 +1,590 @@ +package noppes.npcs.client.gui; + +import com.ibm.icu.text.ArabicShaping; +import com.ibm.icu.text.ArabicShapingException; +import com.ibm.icu.text.Bidi; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; +import noppes.npcs.CustomNpcs; +import noppes.npcs.controllers.data.Quest; +import org.lwjgl.opengl.GL11; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; + +public class OverlayQuestTracking extends Gui { + public Minecraft mc; + + private ScaledResolution res = null; + public static int scaledWidth = 0; + public static int scaledHeight = 0; + + int color = 0xFFFFFF; + float alpha = 1.0F; + + private boolean randomStyle = false; + private boolean boldStyle = false; + private boolean italicStyle = false; + private boolean underlineStyle = false; + private boolean strikethroughStyle = false; + private boolean bidiFlag = false; + private boolean unicodeFlag = false; + + private static final ResourceLocation[] unicodePageLocations = new ResourceLocation[256]; + private final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; + protected final ResourceLocation locationFontTexture = new ResourceLocation("textures/font/ascii.png");; + protected int[] charWidth = new int[256]; + protected byte[] glyphWidth = new byte[65536]; + private final int[] colorCode = new int[32]; + + private float red; + private float green; + private float blue; + + private float posX; + private float posY; + + private float renderOffsetY; + + public static Quest trackedQuest = new Quest(); + public static String categoryName = ""; + + public OverlayQuestTracking(Minecraft mc) { + this.mc = mc; + readFontTexture(); + readGlyphSizes(); + for (int i = 0; i < 32; ++i) + { + int j = (i >> 3 & 1) * 85; + int k = (i >> 2 & 1) * 170 + j; + int l = (i >> 1 & 1) * 170 + j; + int i1 = (i >> 0 & 1) * 170 + j; + + if (i == 6) + { + k += 85; + } + + if (Minecraft.getMinecraft().gameSettings.anaglyph) + { + int j1 = (k * 30 + l * 59 + i1 * 11) / 100; + int k1 = (k * 30 + l * 70) / 100; + int l1 = (k * 30 + i1 * 70) / 100; + k = j1; + l = k1; + i1 = l1; + } + + if (i >= 16) + { + k /= 4; + l /= 4; + i1 /= 4; + } + + this.colorCode[i] = (k & 255) << 16 | (l & 255) << 8 | i1 & 255; + } + } + + public void initOverlay() { + res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + scaledWidth = res.getScaledWidth(); + scaledHeight = res.getScaledHeight(); + } + + public void setOverlayData(NBTTagCompound compound) { + trackedQuest.readNBT(compound.getCompoundTag("Quest")); + categoryName = compound.getString("CategoryName"); + this.initOverlay(); + } + + public void renderGameOverlay(float partialTicks){ + res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + scaledWidth = res.getScaledWidth(); + scaledHeight = res.getScaledHeight(); + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GL11.glDisable(GL11.GL_ALPHA_TEST); + + GL11.glPushMatrix(); + GL11.glTranslatef(CustomNpcs.TrackingInfoAlignment%3*((float)(scaledWidth)/2), (float) (Math.floor((float)(CustomNpcs.TrackingInfoAlignment/3))*((float)(scaledHeight)/2)),0.0F); + GL11.glTranslatef(CustomNpcs.TrackingInfoX - 10, CustomNpcs.TrackingInfoY, 0.0F); + + red = (color >> 16 & 255) / 255f; + green = (color >> 8 & 255) / 255f; + blue = (color & 255) / 255f; + + float centerX = -60; + float questTitleTop; + this.renderOffsetY = -40; + GL11.glPushMatrix(); + GL11.glTranslatef(centerX, 0.0F, 0.0F); + this.renderStringLines(trackedQuest.getName(),1.2F, false, true); + GL11.glPopMatrix(); + questTitleTop = this.renderOffsetY; + this.renderOffsetY -= 5; + GL11.glPushMatrix(); + GL11.glTranslatef(centerX, 0.0F, 0.0F); + this.renderStringLines(categoryName,0.85F, false, false); + GL11.glPopMatrix(); + + //TODO: Add objectives list, with green strikethrough text for completed objectives. Then, add who the player should turn the quest in to. + + this.renderOffsetY = -25; + GL11.glPushMatrix(); + this.drawHorizontalLine((int)(-60 + centerX), (int)(60 + centerX), (int) (this.renderOffsetY+2), 0xFF777777); + this.drawHorizontalLine((int)(-60 + centerX), (int)(60 + centerX), (int) (this.renderOffsetY+1), 0xFFA8A8A8); + this.drawHorizontalLine((int)(-60 + centerX), (int)(60 + centerX), (int) (this.renderOffsetY), 0xFFFFFFFF); + GL11.glPopMatrix(); + this.renderOffsetY = questTitleTop + 5; + GL11.glPushMatrix(); + this.drawHorizontalLine((int)(-60 + centerX), (int)(60 + centerX), (int) (this.renderOffsetY), 0xFFFFFFFF); + this.drawHorizontalLine((int)(-60 + centerX), (int)(60 + centerX), (int) (this.renderOffsetY-1), 0xFFA8A8A8); + this.drawHorizontalLine((int)(-60 + centerX), (int)(60 + centerX), (int) (this.renderOffsetY-2), 0xFF777777); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + + public void renderStringLines(String string, float scale, boolean upwards, boolean bold) { + String[] split = string.split(" "); + + ArrayList lines = new ArrayList<>(); + lines.add(split[0]); + + for (int i = 1; i < split.length; i++) { + String s = split[i]; + if (this.fontRenderer.getStringWidth(lines.get(lines.size() - 1) + " " + s) > 100) { + lines.add(s); + } else { + lines.set(lines.size() - 1, lines.get(lines.size() - 1) + " " + s); + } + } + + for (int i = 0; i < lines.size(); i++) { + String s = lines.get(i); + if (!upwards) { + s = lines.get(lines.size()-1 - i); + } + + GL11.glPushMatrix(); + GL11.glTranslatef(scale*(-this.fontRenderer.getStringWidth(s)/2.0F), this.renderOffsetY, 0.0F); + GL11.glScalef(scale, scale, scale); + this.drawString(s, 0, 0, this.color, true); + if (bold) { + GL11.glTranslatef(0.2F, 0.2F, 0.0F); + this.drawString(s, 0, 0, this.color, false); + } + this.renderOffsetY += upwards ? 10 : -10; + GL11.glPopMatrix(); + } + } + + public int drawString(String p_85187_1_, int p_85187_2_, int p_85187_3_, int p_85187_4_, boolean p_85187_5_) + { + this.resetStyles(); + int l; + + if (p_85187_5_) + { + l = this.renderString(p_85187_1_, p_85187_2_ + 1, p_85187_3_ + 1, p_85187_4_, true); + l = Math.max(l, this.renderString(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false)); + } + else + { + l = this.renderString(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false); + } + + return l; + } + + private void resetStyles() + { + this.randomStyle = false; + this.boldStyle = false; + this.italicStyle = false; + this.underlineStyle = false; + this.strikethroughStyle = false; + } + + private int renderString(String p_78258_1_, int p_78258_2_, int p_78258_3_, int p_78258_4_, boolean p_78258_5_) + { + if (p_78258_1_ == null) + { + return 0; + } + else + { + if (this.bidiFlag) + { + p_78258_1_ = this.bidiReorder(p_78258_1_); + } + + setColor(this.red, this.green, this.blue, this.alpha); + if (p_78258_5_) { + setColor(0,0,0,1.0F); + } + this.posX = (float)p_78258_2_; + this.posY = (float)p_78258_3_; + this.renderStringAtPos(p_78258_1_, p_78258_5_); + return (int)this.posX; + } + } + + private void renderStringAtPos(String p_78255_1_, boolean p_78255_2_) + { + for (int i = 0; i < p_78255_1_.length(); ++i) + { + char c0 = p_78255_1_.charAt(i); + int j; + int k; + + if (c0 == 38 && i + 1 < p_78255_1_.length()) + { + j = "0123456789abcdefklmnor".indexOf(p_78255_1_.toLowerCase().charAt(i + 1)); + + if(j < 16){ + this.randomStyle = false; + this.boldStyle = false; + this.strikethroughStyle = false; + this.underlineStyle = false; + this.italicStyle = false; + + if (j < 0 || j > 15) + { + j = 15; + } + + if (p_78255_2_) + { + j += 16; + } + + k = this.colorCode[j]; + setColor((float)(k >> 16) / 255.0F, (float)(k >> 8 & 255) / 255.0F, (float)(k & 255) / 255.0F, this.alpha); + } + else if (j == 16) + { + this.randomStyle = true; + } + else if (j == 17) + { + this.boldStyle = true; + } + else if (j == 18) + { + this.strikethroughStyle = true; + } + else if (j == 19) + { + this.underlineStyle = true; + } + else if (j == 20) + { + this.italicStyle = true; + } + else if (j == 21) + { + this.randomStyle = false; + this.boldStyle = false; + this.strikethroughStyle = false; + this.underlineStyle = false; + this.italicStyle = false; + } + + ++i; + } + else + { + j = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(c0); + + if (this.randomStyle && j != -1) + { + do + { + k = Minecraft.getMinecraft().fontRenderer.fontRandom.nextInt(this.charWidth.length); + } + while (this.charWidth[j] != this.charWidth[k]); + + j = k; + } + + float f1 = this.unicodeFlag ? 0.5F : 1.0F; + boolean flag1 = (c0 == 0 || j == -1 || this.unicodeFlag) && p_78255_2_; + + if (flag1) + { + this.posX -= f1; + this.posY -= f1; + } + + float f = this.renderCharAtPos(j, c0, this.italicStyle); + + if (flag1) + { + this.posX += f1; + this.posY += f1; + } + + if (this.boldStyle) + { + this.posX += f1; + + if (flag1) + { + this.posX -= f1; + this.posY -= f1; + } + + this.renderCharAtPos(j, c0, this.italicStyle); + this.posX -= f1; + + if (flag1) + { + this.posX += f1; + this.posY += f1; + } + + ++f; + } + + doDraw(f); + } + } + } + + protected void doDraw(float f) + { + { + { + Tessellator tessellator; + + if (this.strikethroughStyle) + { + tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D); + tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D); + tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D); + tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + if (this.underlineStyle) + { + tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + int l = this.underlineStyle ? -1 : 0; + tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D); + tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D); + tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D); + tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + this.posX += (float)((int)f); + } + } + } + + private float renderCharAtPos(int p_78278_1_, char p_78278_2_, boolean p_78278_3_) + { + return p_78278_2_ == 32 ? 4.0F : ("\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(p_78278_2_) != -1 && !this.unicodeFlag ? this.renderDefaultChar(p_78278_1_, p_78278_3_) : this.renderUnicodeChar(p_78278_2_, p_78278_3_)); + } + + protected float renderDefaultChar(int p_78266_1_, boolean p_78266_2_) + { + float f = (float)(p_78266_1_ % 16 * 8); + float f1 = (float)(p_78266_1_ / 16 * 8); + float f2 = p_78266_2_ ? 1.0F : 0.0F; + bindTexture(this.locationFontTexture); + float f3 = (float)this.charWidth[p_78266_1_] - 0.01F; + GL11.glBegin(GL11.GL_TRIANGLE_STRIP); + GL11.glTexCoord2f(f / 128.0F, f1 / 128.0F); + GL11.glVertex3f(this.posX + f2, this.posY, 0.0F); + GL11.glTexCoord2f(f / 128.0F, (f1 + 7.99F) / 128.0F); + GL11.glVertex3f(this.posX - f2, this.posY + 7.99F, 0.0F); + GL11.glTexCoord2f((f + f3 - 1.0F) / 128.0F, f1 / 128.0F); + GL11.glVertex3f(this.posX + f3 - 1.0F + f2, this.posY, 0.0F); + GL11.glTexCoord2f((f + f3 - 1.0F) / 128.0F, (f1 + 7.99F) / 128.0F); + GL11.glVertex3f(this.posX + f3 - 1.0F - f2, this.posY + 7.99F, 0.0F); + GL11.glEnd(); + return (float)this.charWidth[p_78266_1_]; + } + + private ResourceLocation getUnicodePageLocation(int p_111271_1_) + { + if (unicodePageLocations[p_111271_1_] == null) + { + unicodePageLocations[p_111271_1_] = new ResourceLocation(String.format("textures/font/unicode_page_%02x.png", new Object[] {Integer.valueOf(p_111271_1_)})); + } + + return unicodePageLocations[p_111271_1_]; + } + + private void loadGlyphTexture(int p_78257_1_) + { + bindTexture(this.getUnicodePageLocation(p_78257_1_)); + } + + /** + * Render a single Unicode character at current (posX,posY) location using one of the /font/glyph_XX.png files... + */ + protected float renderUnicodeChar(char p_78277_1_, boolean p_78277_2_) + { + if (this.glyphWidth[p_78277_1_] == 0) + { + return 0.0F; + } + else + { + int i = p_78277_1_ / 256; + this.loadGlyphTexture(i); + int j = this.glyphWidth[p_78277_1_] >>> 4; + int k = this.glyphWidth[p_78277_1_] & 15; + float f = (float)j; + float f1 = (float)(k + 1); + float f2 = (float)(p_78277_1_ % 16 * 16) + f; + float f3 = (float)((p_78277_1_ & 255) / 16 * 16); + float f4 = f1 - f - 0.02F; + float f5 = p_78277_2_ ? 1.0F : 0.0F; + GL11.glBegin(GL11.GL_TRIANGLE_STRIP); + GL11.glTexCoord2f(f2 / 256.0F, f3 / 256.0F); + GL11.glVertex3f(this.posX + f5, this.posY, 0.0F); + GL11.glTexCoord2f(f2 / 256.0F, (f3 + 15.98F) / 256.0F); + GL11.glVertex3f(this.posX - f5, this.posY + 7.99F, 0.0F); + GL11.glTexCoord2f((f2 + f4) / 256.0F, f3 / 256.0F); + GL11.glVertex3f(this.posX + f4 / 2.0F + f5, this.posY, 0.0F); + GL11.glTexCoord2f((f2 + f4) / 256.0F, (f3 + 15.98F) / 256.0F); + GL11.glVertex3f(this.posX + f4 / 2.0F - f5, this.posY + 7.99F, 0.0F); + GL11.glEnd(); + return (f1 - f) / 2.0F + 1.0F; + } + } + + protected void setColor(float r, float g, float b, float a) + { + GL11.glColor4f(r, g, b, a); + } + + protected void bindTexture(ResourceLocation location) + { + Minecraft.getMinecraft().renderEngine.bindTexture(location); + } + + private void readFontTexture() + { + BufferedImage bufferedimage; + + try + { + bufferedimage = ImageIO.read(getResourceInputStream(this.locationFontTexture)); + } + catch (IOException ioexception) + { + throw new RuntimeException(ioexception); + } + + int i = bufferedimage.getWidth(); + int j = bufferedimage.getHeight(); + int[] aint = new int[i * j]; + bufferedimage.getRGB(0, 0, i, j, aint, 0, i); + int k = j / 16; + int l = i / 16; + byte b0 = 1; + float f = 8.0F / (float)l; + int i1 = 0; + + while (i1 < 256) + { + int j1 = i1 % 16; + int k1 = i1 / 16; + + if (i1 == 32) + { + this.charWidth[i1] = 3 + b0; + } + + int l1 = l - 1; + + while (true) + { + if (l1 >= 0) + { + int i2 = j1 * l + l1; + boolean flag = true; + + for (int j2 = 0; j2 < k && flag; ++j2) + { + int k2 = (k1 * l + j2) * i; + + if ((aint[i2 + k2] >> 24 & 255) != 0) + { + flag = false; + } + } + + if (flag) + { + --l1; + continue; + } + } + + ++l1; + this.charWidth[i1] = (int)(0.5D + (double)((float)l1 * f)) + b0; + ++i1; + break; + } + } + } + + private void readGlyphSizes() + { + try + { + InputStream inputstream = getResourceInputStream(new ResourceLocation("font/glyph_sizes.bin")); + inputstream.read(this.glyphWidth); + } + catch (IOException ioexception) + { + throw new RuntimeException(ioexception); + } + } + + protected InputStream getResourceInputStream(ResourceLocation location) throws IOException + { + return Minecraft.getMinecraft().getResourceManager().getResource(location).getInputStream(); + } + + private String bidiReorder(String p_147647_1_) + { + try + { + Bidi bidi = new Bidi((new ArabicShaping(8)).shape(p_147647_1_), 127); + bidi.setReorderingMode(0); + return bidi.writeReordered(2); + } + catch (ArabicShapingException arabicshapingexception) + { + return p_147647_1_; + } + } +} diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiQuestLog.java b/src/main/java/noppes/npcs/client/gui/player/GuiQuestLog.java index 9f7ea6341..869eed25b 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiQuestLog.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiQuestLog.java @@ -13,16 +13,12 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import noppes.npcs.NoppesUtilPlayer; import noppes.npcs.QuestLogData; +import noppes.npcs.client.Client; import noppes.npcs.client.CustomNpcResourceListener; import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.TextBlockClient; -import noppes.npcs.client.gui.util.GuiButtonNextPage; -import noppes.npcs.client.gui.util.GuiCustomScroll; -import noppes.npcs.client.gui.util.GuiMenuSideButton; -import noppes.npcs.client.gui.util.GuiNPCInterface; -import noppes.npcs.client.gui.util.ICustomScrollListener; -import noppes.npcs.client.gui.util.IGuiData; -import noppes.npcs.client.gui.util.ITopButtonListener; +import noppes.npcs.client.gui.util.*; +import noppes.npcs.constants.EnumPacketServer; import noppes.npcs.constants.EnumPlayerPacket; import org.lwjgl.opengl.GL11; @@ -33,16 +29,16 @@ import tconstruct.client.tabs.TabRegistry; public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,ICustomScrollListener, IGuiData{ private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png"); - + private EntityPlayer player; private GuiCustomScroll scroll; private HashMap sideButtons = new HashMap(); private QuestLogData data = new QuestLogData(); private boolean noQuests = false; private boolean questDetails = true; - + private Minecraft mc = Minecraft.getMinecraft(); - + public GuiQuestLog(EntityPlayer player) { super(); this.player = player; @@ -58,7 +54,7 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I TabRegistry.addTabsToList(buttonList); TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabQuests.class); - + noQuests = false; if(data.categories.isEmpty()){ @@ -76,10 +72,10 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I i++; } sideButtons.get(categories.indexOf(data.selectedCategory)).active = true; - + if(scroll == null) scroll = new GuiCustomScroll(this,0); - + scroll.setList(data.categories.get(data.selectedCategory)); scroll.setSize(134, 174); scroll.guiLeft = guiLeft + 5; @@ -89,21 +85,32 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I addButton(new GuiButtonNextPage(1, guiLeft + 286, guiTop + 176, true)); addButton(new GuiButtonNextPage(2, guiLeft + 144, guiTop + 176, false)); + GuiNpcButton trackingButton = new GuiNpcButton(3, guiLeft + 260, guiTop + 151, 50, 20, new String[]{"Track", "Tracking"}, data.trackedQuestKey.equals(data.selectedCategory + ":" + data.selectedQuest) ? 1 : 0); + if (trackingButton.displayString.equals("Tracking")) { + trackingButton.packedFGColour = 0x32CD32; + } + addButton(trackingButton); + getButton(1).visible = questDetails && data.hasSelectedQuest(); getButton(2).visible = !questDetails && data.hasSelectedQuest(); + getButton(3).visible = !data.selectedQuest.isEmpty() && getButton(1).visible; } @Override protected void actionPerformed(GuiButton guibutton){ - if(!(guibutton instanceof GuiButtonNextPage)) - return; if(guibutton.id == 1){ questDetails = false; - initGui(); } if(guibutton.id == 2){ questDetails = true; - initGui(); } + if(guibutton.id == 3){ + if (!data.trackedQuestKey.equals(data.selectedCategory + ":" + data.selectedQuest)) { + data.trackedQuestKey = data.selectedCategory + ":" + data.selectedQuest; + } else { + data.trackedQuestKey = ""; + } + } + initGui(); } @Override public void drawScreen(int i, int j, float f){ @@ -115,7 +122,7 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I drawTexturedModalRect(guiLeft, guiTop, 0, 0, 252, 195); drawTexturedModalRect(guiLeft + 252, guiTop, 188, 0, 67, 195); super.drawScreen(i, j, f); - + if(noQuests){ mc.fontRenderer.drawString(StatCollector.translateToLocal("quest.noquests"),guiLeft + 84,guiTop + 80, CustomNpcResourceListener.DefaultTextColor); return; @@ -127,18 +134,17 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I if(!data.hasSelectedQuest()) return; - - if(questDetails){ + + if (questDetails) { drawProgress(); String title = StatCollector.translateToLocal("gui.text"); mc.fontRenderer.drawString(title, guiLeft + 284 - mc.fontRenderer.getStringWidth(title), guiTop + 179, CustomNpcResourceListener.DefaultTextColor); - } - else{ + } else { drawQuestText(); String title = StatCollector.translateToLocal("quest.objectives"); mc.fontRenderer.drawString(title, guiLeft + 168, guiTop + 179, CustomNpcResourceListener.DefaultTextColor); } - + GL11.glPushMatrix(); GL11.glTranslatef(guiLeft + 148, guiTop, 0); GL11.glScalef(1.24f, 1.24f, 1.24f); @@ -146,21 +152,21 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I GL11.glPopMatrix(); drawHorizontalLine(guiLeft + 142, guiLeft + 312, guiTop + 17, + 0xFF000000 + CustomNpcResourceListener.DefaultTextColor); } - + private void drawQuestText(){ TextBlockClient block = new TextBlockClient(data.getQuestText(), 174, true, player); - int yoffset = guiTop + 5; + int yoffset = guiTop + 5; for(int i = 0; i < block.lines.size(); i++){ String text = block.lines.get(i).getFormattedText(); fontRendererObj.drawString(text, guiLeft + 142, guiTop + 20 + (i * fontRendererObj.FONT_HEIGHT), CustomNpcResourceListener.DefaultTextColor); } } - + private void drawProgress() { String complete = data.getComplete(); if(complete != null && !complete.isEmpty()) mc.fontRenderer.drawString(StatCollector.translateToLocalFormatted("quest.completewith", complete), guiLeft + 144, guiTop + 105, CustomNpcResourceListener.DefaultTextColor); - + int yoffset = guiTop + 22; for(String process : data.getQuestStatus()){ int index = process.lastIndexOf(":"); @@ -179,7 +185,7 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I yoffset += 10; } } - + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { } @@ -235,10 +241,16 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I this.data = data; initGui(); } - @Override + + @Override + public void onGuiClosed() { + super.onGuiClosed(); + this.save(); + } + + @Override public void save() { - // TODO Auto-generated method stub - + Client.sendData(EnumPacketServer.UpdateTrackedQuest, this.data.trackedQuestKey); } } diff --git a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java index ac1a762f6..c8c005025 100644 --- a/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java +++ b/src/main/java/noppes/npcs/client/renderer/RenderCNPCPlayer.java @@ -135,7 +135,7 @@ public class RenderCNPCPlayer extends RenderPlayer { } } } else if(player.getEntityData().hasKey("SkinOverlayData")) { - Client.sendData(EnumPacketServer.SERVER_UPDATE_SKIN_OVERLAYS, new Object[0]); + Client.sendData(EnumPacketServer.ServerUpdateSkinOverlays, new Object[0]); } } } @@ -332,7 +332,7 @@ public class RenderCNPCPlayer extends RenderPlayer { postRenderOverlay(player); } } else if(player.getEntityData().hasKey("SkinOverlayData")) { - Client.sendData(EnumPacketServer.SERVER_UPDATE_SKIN_OVERLAYS, new Object[0]); + Client.sendData(EnumPacketServer.ServerUpdateSkinOverlays, new Object[0]); } } diff --git a/src/main/java/noppes/npcs/constants/EnumPacketClient.java b/src/main/java/noppes/npcs/constants/EnumPacketClient.java index 3ab209708..8f9f6ffa1 100644 --- a/src/main/java/noppes/npcs/constants/EnumPacketClient.java +++ b/src/main/java/noppes/npcs/constants/EnumPacketClient.java @@ -34,9 +34,10 @@ public enum EnumPacketClient { DIALOG_DUMMY, CONFIG, ISGUIOPEN, - OVERLAY_DATA, - OVERLAY_CLOSE, + SCRIPT_OVERLAY_DATA, + SCRIPT_OVERLAY_CLOSE, SWING_PLAYER_ARM, UPDATE_ITEM, - PLAYER_UPDATE_SKIN_OVERLAYS + PLAYER_UPDATE_SKIN_OVERLAYS, + OVERLAY_QUEST_TRACKING } diff --git a/src/main/java/noppes/npcs/constants/EnumPacketServer.java b/src/main/java/noppes/npcs/constants/EnumPacketServer.java index d33490c9d..2170f41f1 100644 --- a/src/main/java/noppes/npcs/constants/EnumPacketServer.java +++ b/src/main/java/noppes/npcs/constants/EnumPacketServer.java @@ -79,7 +79,7 @@ public enum EnumPacketServer { MovingPathSave(CustomNpcsPermissions.TOOL_PATHER,true), MovingPathGet(true), DialogNpcGet, - RecipesGet, RecipeGet, QuestOpenGui, PlayerDataGet, + RecipesGet, RecipeGet, QuestOpenGui, PlayerDataGet, UpdateTrackedQuest, RemoteNpcsGet(CustomNpcsPermissions.NPC_GUI), RemoteTpToNpc,QuestGet, QuestCategoryGet, @@ -89,7 +89,7 @@ public enum EnumPacketServer { CustomGuiButton,CustomGuiSlotChange,CustomGuiScrollClick,CustomGuiClose,CustomGuiUnfocused, - SERVER_UPDATE_SKIN_OVERLAYS; + ServerUpdateSkinOverlays; public CustomNpcsPermissions.Permission permission = null; public boolean needsNpc = false; diff --git a/src/main/java/noppes/npcs/controllers/CustomGuiController.java b/src/main/java/noppes/npcs/controllers/CustomGuiController.java index 05451aa73..6627fc649 100644 --- a/src/main/java/noppes/npcs/controllers/CustomGuiController.java +++ b/src/main/java/noppes/npcs/controllers/CustomGuiController.java @@ -40,11 +40,11 @@ public class CustomGuiController { } public static void openOverlay(IPlayer player, ScriptOverlay gui) { - Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.OVERLAY_DATA, new Object[]{gui.toNBT()}); + Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.SCRIPT_OVERLAY_DATA, new Object[]{gui.toNBT()}); } public static boolean updateOverlay(IPlayer player, ScriptOverlay gui) { - Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.OVERLAY_DATA, new Object[]{gui.toNBT()}); + Server.sendData((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.SCRIPT_OVERLAY_DATA, new Object[]{gui.toNBT()}); return true; } diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java b/src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java index 4fdbd6b5b..d02218ef4 100644 --- a/src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java +++ b/src/main/java/noppes/npcs/controllers/data/PlayerQuestData.java @@ -15,8 +15,11 @@ import noppes.npcs.controllers.PlayerDataController; import noppes.npcs.controllers.QuestController; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.quests.QuestInterface; +import noppes.npcs.scripted.interfaces.handler.data.IQuest; public class PlayerQuestData { + public IQuest trackedQuest = null; + public HashMap activeQuests = new HashMap(); public HashMap finishedQuests = new HashMap(); @@ -52,7 +55,8 @@ public class PlayerQuestData { } this.activeQuests = activeQuests; } - + + this.trackedQuest = QuestController.instance.get(mainCompound.getInteger("TrackedQuestID")); } public void saveNBTData(NBTTagCompound maincompound) { @@ -78,6 +82,12 @@ public class PlayerQuestData { compound.setTag("ActiveQuests", list2); maincompound.setTag("QuestData", compound); + + if (this.trackedQuest != null) { + maincompound.setInteger("TrackedQuestID", this.trackedQuest.getId()); + } else { + maincompound.setInteger("TrackedQuestID", -1); + } } public QuestData getQuestCompletion(EntityPlayer player,EntityNPCInterface npc) { diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java index 1677300c8..646c84123 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java @@ -518,7 +518,7 @@ public class ScriptPlayer extends ScriptLivingBase } public void closeOverlay(int id) { - Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.OVERLAY_CLOSE, id, new NBTTagCompound()); + Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.SCRIPT_OVERLAY_CLOSE, id, new NBTTagCompound()); } public IOverlayHandler getOverlays() {