From 8a4b1fa4f54c4d601fe3e60824dcce217adb8994 Mon Sep 17 00:00:00 2001 From: payonel Date: Mon, 1 Jan 2018 12:02:13 -0800 Subject: [PATCH 1/4] add sheep power - add carpeted capacitor and configurations - remove check for power providing mod - remove localization about power check --- src/main/resources/application.conf | 20 +++++ .../assets/opencomputers/lang/de_DE.lang | 1 - .../assets/opencomputers/lang/en_US.lang | 3 +- .../assets/opencomputers/lang/fr_FR.lang | 1 - .../assets/opencomputers/lang/it_IT.lang | 1 - .../assets/opencomputers/lang/pt_BR.lang | 1 - .../assets/opencomputers/lang/ru_RU.lang | 1 - .../assets/opencomputers/lang/zh_CN.lang | 1 - .../assets/opencomputers/lang/zh_TW.lang | 1 - .../opencomputers/recipes/default.recipes | 8 ++ .../opencomputers/recipes/gregtech.recipes | 4 + .../opencomputers/recipes/hardmode.recipes | 4 + .../textures/blocks/CarpetCapacitorTop.png | Bin 0 -> 767 bytes src/main/scala/li/cil/oc/Constants.scala | 1 + src/main/scala/li/cil/oc/Localization.scala | 2 - src/main/scala/li/cil/oc/Settings.scala | 9 ++- .../scala/li/cil/oc/common/EventHandler.scala | 3 - src/main/scala/li/cil/oc/common/IMC.scala | 4 - .../li/cil/oc/common/block/Capacitor.scala | 1 - .../oc/common/block/CarpetedCapacitor.scala | 17 +++++ .../scala/li/cil/oc/common/init/Blocks.scala | 4 + .../cil/oc/common/tileentity/Capacitor.scala | 2 +- .../common/tileentity/CarpetedCapacitor.scala | 70 ++++++++++++++++++ src/main/scala/li/cil/oc/integration/Mod.java | 2 - .../scala/li/cil/oc/integration/Mods.scala | 34 ++++----- .../opencomputers/ModOpenComputers.scala | 5 ++ 26 files changed, 156 insertions(+), 44 deletions(-) create mode 100644 src/main/resources/assets/opencomputers/textures/blocks/CarpetCapacitorTop.png create mode 100644 src/main/scala/li/cil/oc/common/block/CarpetedCapacitor.scala create mode 100644 src/main/scala/li/cil/oc/common/tileentity/CarpetedCapacitor.scala diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index eb7745abd..8380ae86f 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -599,6 +599,26 @@ opencomputers { nanomachines: 100000 } + # Carpeted Capacitor settings + # Carpeted Capacitors generate power when sheep or ocelots walk on them + # Power is generated when at least 2 of a type of animal are present. + # A single sheep and a single ocelot generates no power. Note that a + # computer constantly flashing the screen from white to black drains + # approximately 36 units of power per second. Thus, as an example with the + # default values, it would take 12 carpeted capacitors and 24 sheep + # (2 each) to keep the charge rate. Or, 6 carpeted capacitors and 12 + # ocelots to do the same. Values are: units of power per carpeted + # capacitor per second with 2 animals of a type. + carpetedCapacitors { + # Chance one animal (per capacitor) will take some damage per minute + # Damage chance is only dealt when power is generated + damageChance: 0.001 + # power generated from ocelots + ocelotPower: 6 + # power generated from sheep + sheepPower: 3 + } + # Default "costs", i.e. how much energy certain operations consume. cost { # The amount of energy a computer consumes per tick when running. diff --git a/src/main/resources/assets/opencomputers/lang/de_DE.lang b/src/main/resources/assets/opencomputers/lang/de_DE.lang index da9e7481f..30f991953 100644 --- a/src/main/resources/assets/opencomputers/lang/de_DE.lang +++ b/src/main/resources/assets/opencomputers/lang/de_DE.lang @@ -196,7 +196,6 @@ oc:gui.Chat.WarningClassTransformer=Es gab §cFehler§f beim Ausführen des Clas oc:gui.Chat.WarningFingerprint=§cWARNUNG§f - ungültige Signatur! Sollte '§a%s§f' sein, aber war '§e%s§f'. Falls du kein Modder bist und die "deobfuscated"-Version des Mods benutzt, solltest du OpenComputers erneut herunterladen, da die JAR, die du benutzt, vermutlich modifiziert wurde. oc:gui.Chat.WarningLink=Link konnte nicht geöffnet werden: %s oc:gui.Chat.WarningLuaFallback=Die native Lua-Implementierung ist nicht verfügbar. Computer können ihren Ausführungszustand nicht speichern. Sie werden automatisch neu starten, sobald ein Chunk neu geladen wird. -oc:gui.Chat.WarningPower=Es ist keine unterstützte, Strom erzeugende Mod verfügbar. Computer, Bildschirme und alle anderen Komponenten werden §lkeine§f Energie benötigen. Installiere eine der folgenden Mods, um Stromnutzung zu ermöglichen: BuildCraft, Electrical Age, IndustrialCraft2, Mekanism oder Thermal Expansion. Deaktiviere Stromverbrauch in der Konfiguration, um diese Warnung auszublenden. oc:gui.Chat.WarningProjectRed=Die verwendete Version von Project: Red ist nicht mit OpenComputers kompatibel. Aktualisiere bitte deine Version von Project: Red. oc:gui.Chat.WarningRecipes=Es gab Fehler beim Laden eines oder mehrerer Rezepte. Einige Gegenstände können unter Umständen nicht gefertigt werden. Bitte wirf einen Blick in deine Log-Datei für weitere Informationen. oc:gui.Chat.WarningSimpleComponent=Eine Erweiterung (deine?) welche das §aSimpleComponent§f-Interface verwendet, hat etwas §efalsch gemacht§f. Komponentenlogik konnte nicht eingefügt werden. Bitte wirf einen Blick in deine Log-Datei für weitere Informationen. diff --git a/src/main/resources/assets/opencomputers/lang/en_US.lang b/src/main/resources/assets/opencomputers/lang/en_US.lang index 281977170..13100f124 100644 --- a/src/main/resources/assets/opencomputers/lang/en_US.lang +++ b/src/main/resources/assets/opencomputers/lang/en_US.lang @@ -8,6 +8,7 @@ tile.oc.adapter.name=Adapter tile.oc.assembler.name=Electronics Assembler tile.oc.cable.name=Cable tile.oc.capacitor.name=Capacitor +tile.oc.carpetedCapacitor.name=Carpeted Capacitor tile.oc.case1.name=Computer Case (Tier 1) tile.oc.case2.name=Computer Case (Tier 2) tile.oc.case3.name=Computer Case (Tier 3) @@ -197,7 +198,6 @@ oc:gui.Chat.WarningClassTransformer=There were §cerrors§f running the class tr oc:gui.Chat.WarningFingerprint=§cWARNING§f - fingerprint mismatch! Expected '§a%s§f' but got '§e%s§f'. Unless you are a modder and are running the deobfuscated version of the mod, it is §lstrongly§f recommended to redownload OpenComputers, because the JAR you are using may have been tampered with. oc:gui.Chat.WarningLink=Could not open link: %s oc:gui.Chat.WarningLuaFallback=Native Lua libraries are not available, computers will not be able to persist their state. They will reboot on chunk reloads. -oc:gui.Chat.WarningPower=No supported power providing mod available. Computers, screens and all other components will §lnot§f require energy. Install one of the following mods to enable power: BuildCraft, Electrical Age, IndustrialCraft2, Mekanism or Thermal Expansion. Disable power in the config to suppress this warning. oc:gui.Chat.WarningProjectRed=You are using a version of Project: Red that is incompatible with OpenComputers. Try updating your version of Project: Red. oc:gui.Chat.WarningRecipes=There were errors loading one or more recipes. Some items may be uncraftable. Please check your log file for more information. oc:gui.Chat.WarningSimpleComponent=An addon (yours?) using the §aSimpleComponent§f interface did §esomething wrong§f. Component logic could not be injected. Please check your log file for more information. @@ -265,6 +265,7 @@ oc:tooltip.APU=This is a CPU with an integrated GPU (or IGP), when you just need oc:tooltip.Assembler=Allows constructing robots and other devices from a number of different computer parts. oc:tooltip.Cable=A cheap way of connecting blocks. oc:tooltip.Capacitor=Stores energy for later use. Can be filled and emptied very quickly. +oc:tooltip.CarpetedCapacitor=Stores energy for later use. Can be filled and emptied very quickly. Charges when Sheep or Ocelots walk on it oc:tooltip.CardBase=As the name indicates, this is the basic building block for all expansion cards. oc:tooltip.Case=The Computer Case is the basic building block for computers and houses the computer's §fextension cards§7, §fRAM§7 and §fhard disks§7.[nl] Slots: §f%s§7 oc:tooltip.Chamelium=Raw material for 3D prints. Do not swallow: may lead to blindness and temporary lack of presence. diff --git a/src/main/resources/assets/opencomputers/lang/fr_FR.lang b/src/main/resources/assets/opencomputers/lang/fr_FR.lang index 25cc596b5..b164ed7f6 100644 --- a/src/main/resources/assets/opencomputers/lang/fr_FR.lang +++ b/src/main/resources/assets/opencomputers/lang/fr_FR.lang @@ -186,7 +186,6 @@ oc:gui.Chat.WarningClassTransformer=Il y a §cerrors§f lancement dans le transf oc:gui.Chat.WarningFingerprint=§cALERTE§f - Disparité d'empreinte digitale! Attendu '§a%s§f' mais eu '§e%s§f'. À moins que vous ne soyez un modder et que vous exécutiez la version deobfuscated du mod, Il est §lfortement§f recommendé de re-télécharger OpenComputers, parce que le JAR que vous utilisez peut avoir été falsifié. oc:gui.Chat.WarningLink=Impossible d'ouvrir le lien : %s oc:gui.Chat.WarningLuaFallback=Les bibliothèques natives Lua ne sont pas disponibles, les ordinateurs ne pourront pas persister en leur état. Ils réamorceront sur la recharge des chunks. -oc:gui.Chat.WarningPower=Aucun mod supporté produisant de la puissance. Les ordinateurs, écrans et autres composants §lne réclamerons pas§f d'énergie. Installez l'un de ses mods pour activer la puissance: BuildCraft, Electrical Age, IndustrialCraft2, Mekanism or Thermal Expansion. Mettez hors service la puissance dans la config pour supprimer cet avertissement. oc:gui.Chat.WarningProjectRed=Vous utilisez une version de Project: Red qui est incompatible avec OpenComputers. Essayez de mettre à jour votre version de Project: Red. oc:gui.Chat.WarningRecipes=il y a des erreurs au lancement de recettes. Certains éléments doivent être infabricables. Veuillez vérifier votre fichier log pour plus d'information. oc:gui.Chat.WarningSimpleComponent=Un ajout (le votre ?) utilisant l'interface §aComposant Simple§f produit §equelquechose de mauvais§f. Le composant logique ne peut être inséré. Veuillez vérifier votre fichier log pour plus d'information. diff --git a/src/main/resources/assets/opencomputers/lang/it_IT.lang b/src/main/resources/assets/opencomputers/lang/it_IT.lang index 9742694bb..3f4a3b46a 100644 --- a/src/main/resources/assets/opencomputers/lang/it_IT.lang +++ b/src/main/resources/assets/opencomputers/lang/it_IT.lang @@ -140,7 +140,6 @@ oc:gui.Assembler.Warning.Screen=Schermo oc:gui.Chat.NewVersion=Una nuova versione è disponibile: %s oc:gui.Chat.WarningFingerprint=§cATTENZIONE§f - mancata corrispondenza dei fingerprint! Atteso '§a%s§f' ma ottenuto '§e%s§f'. Tranne nel caso tu sia un mod che stai utilizzando una versione decomppilata, è §lfortemente§f raccomantado riscaricare OpenComputers, perché il file JAR che stai utilizzando potrebbe essere stato corrotto. oc:gui.Chat.WarningLuaFallback=Le librerie Lua Native non sono disponibili, i computers non saranno in gredo di mantenere il loro stato di persostenza. Essi verranno riavviati quando il chunk viene ricaricato. -oc:gui.Chat.WarningPower=Nessun mod che fornisce energia disponibile. Computer, monitor e tutti gli altri componenti §lnon§f avranno bisogno di energia per funzionare. Installa uno dei seguenti mod per utilizzare il consumo di energia: BuildCraft, Electrical Age, IndustrialCraft2, Mekanism or Thermal Expansion. Disabilita l'utilizzo di energia nella configurazione per rimuovere questo avviso. oc:gui.Chat.WarningProjectRed=Stai utilizzando una versione di Project: Red che è incompatibile con OpenComputers. Prova ad aggriornare la tua versione di Project: Red. oc:gui.Error.ComponentOverflow=Troppi componenti connessi al computer. oc:gui.Error.InternalError=Errore interno, per favore vedi il file di log. Questo è probabilmente un bug. diff --git a/src/main/resources/assets/opencomputers/lang/pt_BR.lang b/src/main/resources/assets/opencomputers/lang/pt_BR.lang index 504c6ef7d..31a23fa6e 100644 --- a/src/main/resources/assets/opencomputers/lang/pt_BR.lang +++ b/src/main/resources/assets/opencomputers/lang/pt_BR.lang @@ -194,7 +194,6 @@ oc:gui.Chat.WarningClassTransformer=Houve um erro §cerros§f ao rodar o 'class oc:gui.Chat.WarningFingerprint=§cATENÇÃO§f - impressão digital não reconhecida! Experado '§a%s§f' mas recebido '§e%s§f'. Há não ser que seja um moderador e esteja rodando uma versão desofuscada, é §lextremamente§f recomendável que baixe novamente o OpenComputers, por que o JAR que está usando talvez esteja adulterado. oc:gui.Chat.WarningLink=Não pode abrir o atalho: %s oc:gui.Chat.WarningLuaFallback=Bibliotecas de LUA nativas não disponíveis, computadores não serão capazes de persistir seus estados. Eles reiniciarizaram com chunkloaders. -oc:gui.Chat.WarningPower=Nenhum mod supprtado que provê energia foi encontrado. Computadores, monitores e todos os outros componentes §lnão§f requiriram energia. Instale um dos mods para habilitar a energia: BuildCraft, Electrical Age, IndustrialCraft2, Mekanism ou Thermal Expansion. Disabilite a energia nas confgurações para que esse aviso não apareça. oc:gui.Chat.WarningProjectRed=Você está usando a versão Project: Red que é incompativel com OpenComputers. Tente atualizar sua versão do Project: Red. oc:gui.Chat.WarningRecipes=Houve erros ao carregar uma ou mais receitas. Algumas não poderão ser construídas. Por favor verifique seu arquivo de log para mais informações. oc:gui.Chat.WarningSimpleComponent=Um addon (seu?) usa a interface §aSimpleComponent§f que faz §ealgo errado§f. A lógica de componente não pode ser injetada. Por favor verifique seu arquivo de log para mais informações. diff --git a/src/main/resources/assets/opencomputers/lang/ru_RU.lang b/src/main/resources/assets/opencomputers/lang/ru_RU.lang index ae2410bc3..ff5cdf945 100644 --- a/src/main/resources/assets/opencomputers/lang/ru_RU.lang +++ b/src/main/resources/assets/opencomputers/lang/ru_RU.lang @@ -196,7 +196,6 @@ oc:gui.Chat.WarningClassTransformer=Возникли §cошибки§f при oc:gui.Chat.WarningFingerprint=§cВНИМАНИЕ§f - несовпадение отпечатка файла! Ожидаемый: '§a%s§f', полученный: '§e%s§f'. Если Вы не разработчик, использующий деобфусцированную версию мода, то §lкрайне§f желательно заново скачать OpenComputers, поскольку JAR-файл, возможно, был изменён. oc:gui.Chat.WarningLink=Невозможно открыть ссылку: %s oc:gui.Chat.WarningLuaFallback=Исходные библиотеки Lua не доступны, компьютеры не смогут сохранять своё состояние. Они перезагрузятся после выгрузки чанка. -oc:gui.Chat.WarningPower=Подходящие моды, предоставляющие энергию, не найдены. Компьютеры, мониторы и прочие компоненты §lне будут§f требовать энергию. Для активации данной функции установите один из следующих модов: BuildCraft, IndustrialCraft2, Thermal Expansion или Resonant Engine. Отключите требование энергии в файле конфигурации, чтобы скрыть это предупреждение. oc:gui.Chat.WarningProjectRed=Вы используете версию Project: Red, несовместимую с OpenComputers. Попробуйте обновить Project: Red. oc:gui.Chat.WarningRecipes=Произошла ошибка при загрузке одного или нескольких рецептов. Некоторые предметы могут не крафтиться. Проверьте логи, чобы узнать подробнее. oc:gui.Chat.WarningSimpleComponent=Некоторый мод §eневерно§f использует интрефейс §aSimpleComponent§f. Логика компонента не смогла быть внедрена. Проверьте логи, чобы узнать подробнее. diff --git a/src/main/resources/assets/opencomputers/lang/zh_CN.lang b/src/main/resources/assets/opencomputers/lang/zh_CN.lang index 6153d4467..0a0680ba9 100644 --- a/src/main/resources/assets/opencomputers/lang/zh_CN.lang +++ b/src/main/resources/assets/opencomputers/lang/zh_CN.lang @@ -195,7 +195,6 @@ oc:gui.Chat.WarningClassTransformer=执行类转换器时发生§c错误§f. 请 oc:gui.Chat.WarningFingerprint=§c警告§f - 指纹校验不匹配! 预期对应 '§a%s§f' 但识别到 '§e%s§f'. 如果您不是模组的作者, 或运行的不是反混淆版本, 我§l强烈§f 建议你重新下载开放式电脑模组, 因为当前使用的JAR文件已被篡改. oc:gui.Chat.WarningLink=无法打开链接: %s oc:gui.Chat.WarningLuaFallback=无法使用原有的Lua库, 电脑不会持续现在的状态. 它们会在区块载入时重启. -oc:gui.Chat.WarningPower=没有检测到可提供能源的模组. 电脑,显示屏和所有其它组件将§l不需要§f能量来运作. 安装下列任意一个组来启用能量需求:建筑(Buildcraft),电子时代(Electrical Age),工业2(IndustrialCraft 2),通用机械(Mekanism)或热力膨胀(Thermal Expansion). 在配置文件中禁用能量设定可以让这条信息不再显示. oc:gui.Chat.WarningProjectRed=你目前使用的Project:Red版本不兼容OpenComputers. 请升级您的Project:Red后再试. oc:gui.Chat.WarningRecipes=加载合成表时遇到一个或多个错误. 部分物品或因此无法合成. 查阅日志文件以获取详细信息. oc:gui.Chat.WarningSimpleComponent=一个(您的?)扩展Mod使用了§aSimpleComponent§f接口但§e做错了一些事情§f. Component logic无法注入. 查阅日志文件以获取详细信息. diff --git a/src/main/resources/assets/opencomputers/lang/zh_TW.lang b/src/main/resources/assets/opencomputers/lang/zh_TW.lang index 31974bf91..277ec5baf 100644 --- a/src/main/resources/assets/opencomputers/lang/zh_TW.lang +++ b/src/main/resources/assets/opencomputers/lang/zh_TW.lang @@ -190,7 +190,6 @@ oc:gui.Chat.WarningClassTransformer=There were §cerrors§f running the class tr oc:gui.Chat.WarningFingerprint=§c警告§f - 指紋不符!預期 '§a%s§f' 但得到 '§e%s§f'. Unless you are a modder and are running the deobfuscated version of the mod, it is §lstrongly§f recommended to redownload OpenComputers, because the JAR you are using may have been tampered with. oc:gui.Chat.WarningLink=無法打開鏈接: %s oc:gui.Chat.WarningLuaFallback=本機 LUA 函式庫無法使用,電腦將無法維持狀態,他會重新啟動並且載入區塊 -oc:gui.Chat.WarningPower=沒有發現支援的能量供應模組. 電腦螢幕與全部其他的電腦設備 §lnot§f 需要能量. 安裝下列模組之一能夠提供能源: BuildCraft 或 IndustrialCraft2. 在配置裡面可以設定不使用這個電源警告 oc:gui.Chat.WarningProjectRed=你正在使用的 Project: Red 模組與 OpenComputers 不相容. 請嘗試更新 Project: Red. oc:gui.Chat.WarningRecipes=There were errors loading one or more recipes. Some items may be uncraftable. Please check your log file for more information. oc:gui.Chat.WarningSimpleComponent=An addon (yours?) using the §aSimpleComponent§f interface did §esomething wrong§f. Component logic could not be injected. Please check your log file for more information. diff --git a/src/main/resources/assets/opencomputers/recipes/default.recipes b/src/main/resources/assets/opencomputers/recipes/default.recipes index 85745834a..c4eb8359d 100644 --- a/src/main/resources/assets/opencomputers/recipes/default.recipes +++ b/src/main/resources/assets/opencomputers/recipes/default.recipes @@ -567,6 +567,14 @@ cable { ["", nuggetIron, ""]] output: 4 } +luaBios { + type: shapeless + input: ["oc:eeprom", "oc:manual"] +} +carpetedCapacitor { + type: shapeless + input: [carpet, "oc:capacitor"] +} capacitor { input: [[ingotIron, "oc:materialTransistor", ingotIron] [nuggetGold, paper, nuggetGold] diff --git a/src/main/resources/assets/opencomputers/recipes/gregtech.recipes b/src/main/resources/assets/opencomputers/recipes/gregtech.recipes index c24ada2d7..16b0d34bf 100644 --- a/src/main/resources/assets/opencomputers/recipes/gregtech.recipes +++ b/src/main/resources/assets/opencomputers/recipes/gregtech.recipes @@ -271,6 +271,10 @@ cable { time: 64 output: 8 } +carpetedCapacitor { + type: shapeless + input: [carpet, "oc:capacitor"] +} capacitor { # 7 = CESU input: [["", {item="ic2.blockElectric", subID=7}, ""] diff --git a/src/main/resources/assets/opencomputers/recipes/hardmode.recipes b/src/main/resources/assets/opencomputers/recipes/hardmode.recipes index e37ff1f05..6b1ecbf97 100644 --- a/src/main/resources/assets/opencomputers/recipes/hardmode.recipes +++ b/src/main/resources/assets/opencomputers/recipes/hardmode.recipes @@ -316,6 +316,10 @@ cable { ["", nuggetIron, ""]] output: 4 } +carpetedCapacitor { + type: shapeless + input: [carpet, "oc:capacitor"] +} capacitor { input: [[ingotIron, "oc:materialTransistor", ingotIron] [nuggetGold, paper, nuggetGold] diff --git a/src/main/resources/assets/opencomputers/textures/blocks/CarpetCapacitorTop.png b/src/main/resources/assets/opencomputers/textures/blocks/CarpetCapacitorTop.png new file mode 100644 index 0000000000000000000000000000000000000000..8e868a1ce06357a080071d4a0983a4fc435086bf GIT binary patch literal 767 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!~g&e!~vBn4jTXf02y>eSaefwW^{L9 za%BKPWN%_+AW3auXJt}lVPtu6$z?nM00M7GL_t(IPhC?@OJV^OJ@2KGX=Yk!Nf?Ua zqLqYeH$g64w3#0pw%0M&H@+0XB$x_pK=Z3;`;oW2&P*oL^$wZ#%``6!;_4W11>FFu9wzj1C;o$+p;Si6Hk5bIf z=jUgvtgK*haS{1^9yXf|YinzWL?Tce4#(vB`Wlr=MH&Ku00x5ry4|icYYSj9neg=V zB%3wF(CKuzySu~A&JI*IU0hsXV`Bpzj|b&)8JCxr7>!2Q-rfd>UtL|nYPHJNo0}VC zG8w7=kHY=^J(iZ1q-cJA9?4`9yy$LOS65f@@$n(@5fME>pRi|tfB#d3VzDUG$&rdsB0{IE z{9Y=RWaz@e0#d0I(&;oT7K_L!{{>PYCq_6Nma8Wc3GoKq#$q~=4&-4O&1O?nkO7=Z zo-81h_xE@7`+dA=2O~N OpenComputers.log.warn("Failed registering ink provider.", t) } } - else if (message.key == "registerCustomPowerSystem" && message.isStringMessage) { - OpenComputers.log.info(s"Was told there is an unknown power system present by mod ${message.getSender}.") - Settings.get.is3rdPartyPowerSystemPresent = message.getStringValue == "true" - } else if (message.key == "registerProgramDiskLabel" && message.isNBTMessage) { OpenComputers.log.info(s"Registering new program location mapping for program '${message.getNBTValue.getString("program")}' being on disk '${message.getNBTValue.getString("label")}' from mod ${message.getSender}.") ProgramLocations.addMapping(message.getNBTValue.getString("program"), message.getNBTValue.getString("label"), message.getNBTValue.getTagList("architectures", NBT.TAG_STRING).map((tag: NBTTagString) => tag.func_150285_a_()).toArray: _*) diff --git a/src/main/scala/li/cil/oc/common/block/Capacitor.scala b/src/main/scala/li/cil/oc/common/block/Capacitor.scala index c98579e37..25093b5b2 100644 --- a/src/main/scala/li/cil/oc/common/block/Capacitor.scala +++ b/src/main/scala/li/cil/oc/common/block/Capacitor.scala @@ -3,7 +3,6 @@ package li.cil.oc.common.block import java.util.Random import li.cil.oc.common.tileentity -import li.cil.oc.integration.Mods import li.cil.oc.integration.coloredlights.ModColoredLights import net.minecraft.block.Block import net.minecraft.world.World diff --git a/src/main/scala/li/cil/oc/common/block/CarpetedCapacitor.scala b/src/main/scala/li/cil/oc/common/block/CarpetedCapacitor.scala new file mode 100644 index 000000000..06d664b26 --- /dev/null +++ b/src/main/scala/li/cil/oc/common/block/CarpetedCapacitor.scala @@ -0,0 +1,17 @@ +package li.cil.oc.common.block + +import li.cil.oc.common.tileentity +import net.minecraft.world.World + +class CarpetedCapacitor extends Capacitor { + override def createTileEntity(world: World, metadata: Int) = new tileentity.CarpetedCapacitor() + + override protected def customTextures = Array( + None, + Some("CarpetCapacitorTop"), + Some("CapacitorSide"), + Some("CapacitorSide"), + Some("CapacitorSide"), + Some("CapacitorSide") + ) +} diff --git a/src/main/scala/li/cil/oc/common/init/Blocks.scala b/src/main/scala/li/cil/oc/common/init/Blocks.scala index 1d4662ad3..a6719ad28 100644 --- a/src/main/scala/li/cil/oc/common/init/Blocks.scala +++ b/src/main/scala/li/cil/oc/common/init/Blocks.scala @@ -15,6 +15,7 @@ object Blocks { GameRegistry.registerTileEntityWithAlternatives(classOf[tileentity.Assembler], Settings.namespace + "assembler", Settings.namespace + "robotAssembler") GameRegistry.registerTileEntity(classOf[tileentity.Cable], Settings.namespace + "cable") GameRegistry.registerTileEntity(classOf[tileentity.Capacitor], Settings.namespace + "capacitor") + GameRegistry.registerTileEntity(classOf[tileentity.CarpetedCapacitor], Settings.namespace + "carpetedCapacitor") GameRegistry.registerTileEntity(classOf[tileentity.Case], Settings.namespace + "case") GameRegistry.registerTileEntity(classOf[tileentity.Charger], Settings.namespace + "charger") GameRegistry.registerTileEntity(classOf[tileentity.DiskDrive], Settings.namespace + "disk_drive") @@ -85,5 +86,8 @@ object Blocks { // v1.5.16 Recipes.addBlock(new Transposer(), Constants.BlockName.Transposer, "oc:transposer") + + // v1.7.2 + Recipes.addBlock(new CarpetedCapacitor(), Constants.BlockName.CarpetedCapacitor, "oc:carpetedCapacitor") } } diff --git a/src/main/scala/li/cil/oc/common/tileentity/Capacitor.scala b/src/main/scala/li/cil/oc/common/tileentity/Capacitor.scala index 825afbe35..d68b58582 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/Capacitor.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/Capacitor.scala @@ -81,5 +81,5 @@ class Capacitor extends traits.Environment with DeviceInfo { private def indirectNeighbors = ForgeDirection.VALID_DIRECTIONS.map(side => (x + side.offsetX * 2, y + side.offsetY * 2, z + side.offsetZ * 2)) - private def maxCapacity = Settings.get.bufferCapacitor + Settings.get.bufferCapacitorAdjacencyBonus * 9 + protected def maxCapacity = Settings.get.bufferCapacitor + Settings.get.bufferCapacitorAdjacencyBonus * 9 } diff --git a/src/main/scala/li/cil/oc/common/tileentity/CarpetedCapacitor.scala b/src/main/scala/li/cil/oc/common/tileentity/CarpetedCapacitor.scala new file mode 100644 index 000000000..e0db016cb --- /dev/null +++ b/src/main/scala/li/cil/oc/common/tileentity/CarpetedCapacitor.scala @@ -0,0 +1,70 @@ +package li.cil.oc.common.tileentity + +import java.util + +import li.cil.oc.Constants +import li.cil.oc.api.driver.DeviceInfo.DeviceAttribute +import li.cil.oc.api.driver.DeviceInfo.DeviceClass +import li.cil.oc.Settings +import net.minecraft.entity.EntityLivingBase +import net.minecraft.entity.passive.{EntityOcelot, EntitySheep} +import net.minecraft.util.{AxisAlignedBB, DamageSource} +import net.minecraftforge.common.util.ForgeDirection + +import scala.collection.convert.WrapAsJava._ +import scala.collection.convert.WrapAsScala._ + +class CarpetedCapacitor extends Capacitor { + private final lazy val deviceInfo = Map( + DeviceAttribute.Class -> DeviceClass.Power, + DeviceAttribute.Description -> "Battery", + DeviceAttribute.Vendor -> Constants.DeviceInfo.DefaultVendor, + DeviceAttribute.Product -> "CarpetedCapBank3x", + DeviceAttribute.Capacity -> maxCapacity.toString + ) + + override def getDeviceInfo: util.Map[String, String] = deviceInfo + + override def canUpdate = true + + private val rng = scala.util.Random + private val chance: Double = Settings.get.carpetDamageChance + private var nextChanceTime: Long = 0 + + private def energyFromGroup(entities: Set[EntityLivingBase], power: Double): Double = { + if (entities.size < 2) return 0 + def tryDamageOne(): Unit = { + for (ent <- entities) { + if (rng.nextDouble() < chance) { + ent.attackEntityFrom(DamageSource.generic, 1) + ent.setRevengeTarget(ent) // panic + ent.knockBack(ent, 0, .25, 0) + // wait a minute before the next possible shock + nextChanceTime = world.getTotalWorldTime + (20 * 60) + return + } + } + } + if (chance > 0 && nextChanceTime < world.getTotalWorldTime) { + tryDamageOne() + } + power + } + + override def updateEntity() { + if (node != null && (world.getTotalWorldTime + hashCode) % 20 == 0) { + val entities = world.getEntitiesWithinAABB(classOf[EntityLivingBase], capacitorPowerBounds) + .map(_.asInstanceOf[EntityLivingBase]) + .filter(entity => entity.isEntityAlive) + .toSet + val sheepPower = energyFromGroup(entities.filter(_.isInstanceOf[EntitySheep]), Settings.get.sheepPower) + val ocelotPower = energyFromGroup(entities.filter(_.isInstanceOf[EntityOcelot]), Settings.get.ocelotPower) + val totalPower = sheepPower + ocelotPower + if (totalPower > 0) { + node.changeBuffer(totalPower) + } + } + } + + private def capacitorPowerBounds = position.offset(ForgeDirection.UP).bounds +} diff --git a/src/main/scala/li/cil/oc/integration/Mod.java b/src/main/scala/li/cil/oc/integration/Mod.java index bc54fe566..e3b299958 100644 --- a/src/main/scala/li/cil/oc/integration/Mod.java +++ b/src/main/scala/li/cil/oc/integration/Mod.java @@ -4,6 +4,4 @@ public interface Mod { String id(); boolean isModAvailable(); - - boolean providesPower(); } diff --git a/src/main/scala/li/cil/oc/integration/Mods.scala b/src/main/scala/li/cil/oc/integration/Mods.scala index 0d7e452a8..7ca2848b6 100644 --- a/src/main/scala/li/cil/oc/integration/Mods.scala +++ b/src/main/scala/li/cil/oc/integration/Mods.scala @@ -13,14 +13,12 @@ object Mods { private val knownMods = mutable.ArrayBuffer.empty[ModBase] - lazy val isPowerProvidingModPresent = knownMods.exists(mod => mod.providesPower && mod.isAvailable) - // ----------------------------------------------------------------------- // def All = knownMods.clone() val AgriCraft = new SimpleMod(IDs.AgriCraft, version = "@[1.4.0,)") - val AppliedEnergistics2 = new SimpleMod(IDs.AppliedEnergistics2, version = "@[rv1,)", providesPower = true) + val AppliedEnergistics2 = new SimpleMod(IDs.AppliedEnergistics2, version = "@[rv1,)") val BattleGear2 = new SimpleMod(IDs.BattleGear2) val BetterRecords = new SimpleMod(IDs.BetterRecords) val BloodMagic = new SimpleMod(IDs.BloodMagic) @@ -31,27 +29,27 @@ object Mods { val BuildCraftTiles = new SimpleMod(IDs.BuildCraftTiles) val BuildCraftTools = new SimpleMod(IDs.BuildCraftTools) val BuildCraftTransport = new SimpleMod(IDs.BuildCraftTransport) - val CoFHEnergy = new SimpleMod(IDs.CoFHEnergy, providesPower = true) + val CoFHEnergy = new SimpleMod(IDs.CoFHEnergy) val CoFHItem = new SimpleMod(IDs.CoFHItem) val CoFHTileEntity = new SimpleMod(IDs.CoFHTileEntity) val CoFHTransport = new SimpleMod(IDs.CoFHTransport) val ColoredLights = new SimpleMod(IDs.ColoredLights) val ComputerCraft = new SimpleMod(IDs.ComputerCraft, version = "@[1.73,)") val CraftingCosts = new SimpleMod(IDs.CraftingCosts) - val DeepStorageUnit = new ClassBasedMod(IDs.DeepStorageUnit, "powercrystals.minefactoryreloaded.api.IDeepStorageUnit")() - val ElectricalAge = new SimpleMod(IDs.ElectricalAge, providesPower = true) + val DeepStorageUnit = new ClassBasedMod(IDs.DeepStorageUnit, "powercrystals.minefactoryreloaded.api.IDeepStorageUnit") + val ElectricalAge = new SimpleMod(IDs.ElectricalAge) val EnderIO = new SimpleMod(IDs.EnderIO, version = "@[2.2,2.3)") val EnderStorage = new SimpleMod(IDs.EnderStorage) val ExtraCells = new SimpleMod(IDs.ExtraCells, version = "@[2.2.73,)") - val Factorization = new SimpleMod(IDs.Factorization, providesPower = true) + val Factorization = new SimpleMod(IDs.Factorization) val Forestry = new SimpleMod(IDs.Forestry, version = "@[4.0,)") val ForgeMultipart = new SimpleMod(IDs.ForgeMultipart) - val Galacticraft = new SimpleMod(IDs.Galacticraft, providesPower = true) - val GregTech = new ClassBasedMod(IDs.GregTech, "gregtech.api.GregTech_API")() - val IndustrialCraft2 = new SimpleMod(IDs.IndustrialCraft2, providesPower = true) - val IndustrialCraft2Classic = new SimpleMod(IDs.IndustrialCraft2Classic, providesPower = true) + val Galacticraft = new SimpleMod(IDs.Galacticraft) + val GregTech = new ClassBasedMod(IDs.GregTech, "gregtech.api.GregTech_API") + val IndustrialCraft2 = new SimpleMod(IDs.IndustrialCraft2) + val IndustrialCraft2Classic = new SimpleMod(IDs.IndustrialCraft2Classic) val IngameWiki = new SimpleMod(IDs.IngameWiki, version = "@[1.1.3,)") - val Mekanism = new SimpleMod(IDs.Mekanism, providesPower = true) + val Mekanism = new SimpleMod(IDs.Mekanism) val MekanismGas = new SimpleMod(IDs.MekanismGas) val Minecraft = new SimpleMod(IDs.Minecraft) val MineFactoryReloaded = new SimpleMod(IDs.MineFactoryReloaded) @@ -77,7 +75,7 @@ object Mods { } val Thaumcraft = new SimpleMod(IDs.Thaumcraft) val ThaumicEnergistics = new SimpleMod(IDs.ThaumicEnergistics) - val ThermalExpansion = new SimpleMod(IDs.ThermalExpansion, providesPower = true) + val ThermalExpansion = new SimpleMod(IDs.ThermalExpansion) val TinkersConstruct = new SimpleMod(IDs.TinkersConstruct) val TIS3D = new SimpleMod(IDs.TIS3D, version = "@[0.7,)") val TMechWorks = new SimpleMod(IDs.TMechWorks) @@ -235,15 +233,11 @@ object Mods { private var powerDisabled = false - protected lazy val isPowerModEnabled = !providesPower || (!Settings.get.pureIgnorePower && !Settings.get.powerModBlacklist.contains(id)) - def isModAvailable: Boolean def id: String - def isAvailable = !powerDisabled && isModAvailable && isPowerModEnabled - - def providesPower: Boolean = false + def isAvailable = isModAvailable // This is called from the class transformer when injecting an interface of // this power type fails, to avoid class not found / class cast exceptions. @@ -254,7 +248,7 @@ object Mods { def version = container.map(_.getProcessedVersion) } - class SimpleMod(val id: String, override val providesPower: Boolean = false, version: String = "") extends ModBase { + class SimpleMod(val id: String, version: String = "") extends ModBase { private lazy val isModAvailable_ = { val version = VersionParser.parseVersionReference(id + this.version) if (Loader.isModLoaded(version.getLabel)) @@ -265,7 +259,7 @@ object Mods { def isModAvailable = isModAvailable_ } - class ClassBasedMod(val id: String, val classNames: String*)(override val providesPower: Boolean = false) extends ModBase { + class ClassBasedMod(val id: String, val classNames: String*) extends ModBase { private lazy val isModAvailable_ = classNames.forall(className => try Class.forName(className) != null catch { case _: Throwable => false }) diff --git a/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala b/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala index 681aee72b..e7971e5ad 100644 --- a/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala +++ b/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala @@ -210,6 +210,7 @@ object ModOpenComputers extends ModProxy { Constants.BlockName.Keyboard, Constants.BlockName.ScreenTier1, Constants.BlockName.Transposer, + Constants.BlockName.CarpetedCapacitor, Constants.ItemName.AngelUpgrade, Constants.ItemName.BatteryUpgradeTier1, Constants.ItemName.BatteryUpgradeTier2, @@ -232,6 +233,7 @@ object ModOpenComputers extends ModProxy { Constants.BlockName.Keyboard, Constants.BlockName.ScreenTier1, Constants.BlockName.Transposer, + Constants.BlockName.CarpetedCapacitor, Constants.ItemName.APUTier1, Constants.ItemName.APUTier2, Constants.ItemName.GraphicsCardTier1, @@ -246,6 +248,7 @@ object ModOpenComputers extends ModProxy { blacklistHost(classOf[internal.Microcontroller], Constants.BlockName.Keyboard, Constants.BlockName.ScreenTier1, + Constants.BlockName.CarpetedCapacitor, Constants.ItemName.APUTier1, Constants.ItemName.APUTier2, Constants.ItemName.GraphicsCardTier1, @@ -271,10 +274,12 @@ object ModOpenComputers extends ModProxy { Constants.ItemName.TradingUpgrade) blacklistHost(classOf[internal.Robot], Constants.BlockName.Transposer, + Constants.BlockName.CarpetedCapacitor, Constants.ItemName.LeashUpgrade) blacklistHost(classOf[internal.Tablet], Constants.BlockName.ScreenTier1, Constants.BlockName.Transposer, + Constants.BlockName.CarpetedCapacitor, Constants.ItemName.NetworkCard, Constants.ItemName.RedstoneCardTier1, Constants.ItemName.AngelUpgrade, From f8bfbf55b153b1efd3e83d06d46d5e0657ad40ef Mon Sep 17 00:00:00 2001 From: payonel Date: Tue, 2 Jan 2018 20:59:09 -0800 Subject: [PATCH 2/4] make component inventory components array even more lazy allow a component inventory to define its inventory size from nbt even after the components array has been accessed. The array will appear to be size zero until initialized closes #2522 --- .../common/inventory/ComponentInventory.scala | 29 +++++++++++++++---- .../li/cil/oc/common/tileentity/Case.scala | 8 ++++- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/main/scala/li/cil/oc/common/inventory/ComponentInventory.scala b/src/main/scala/li/cil/oc/common/inventory/ComponentInventory.scala index 6aa9c5349..8caf654c8 100644 --- a/src/main/scala/li/cil/oc/common/inventory/ComponentInventory.scala +++ b/src/main/scala/li/cil/oc/common/inventory/ComponentInventory.scala @@ -17,7 +17,16 @@ import scala.collection.convert.WrapAsScala._ import scala.collection.mutable trait ComponentInventory extends Inventory with network.Environment { - lazy val components = Array.fill[Option[ManagedEnvironment]](getSizeInventory)(None) + private var _components: Array[Option[ManagedEnvironment]] = _ + protected var isSizeInventoryReady: Boolean = true + + def components: Array[Option[ManagedEnvironment]] = { + if (_components == null && isSizeInventoryReady) { + _components = Array.fill[Option[ManagedEnvironment]](getSizeInventory)(None) + } + if (_components == null) Array[Option[ManagedEnvironment]]() else _components + } + protected val updatingComponents = mutable.ArrayBuffer.empty[ManagedEnvironment] // ----------------------------------------------------------------------- // @@ -99,11 +108,19 @@ trait ComponentInventory extends Inventory with network.Environment { for (slot <- 0 until getSizeInventory) { val stack = getStackInSlot(slot) if (stack != null) { - components(slot) match { - case Some(component) => - // We're guaranteed to have a driver for entries. - save(component, Driver.driverFor(stack), stack) - case _ => // Nothing special to save. + if (slot >= components.length) { + // isSizeInventoryReady was added to resolve issues where an inventory was used before its + // nbt data had been parsed. See https://github.com/MightyPirates/OpenComputers/issues/2522 + // If this error is hit again, perhaps another subtype needs to handle nbt loading like Case does + OpenComputers.log.error(s"ComponentInventory components length ${components.length} does not accommodate inventory size ${getSizeInventory}") + return + } else { + components(slot) match { + case Some(component) => + // We're guaranteed to have a driver for entries. + save(component, Driver.driverFor(stack), stack) + case _ => // Nothing special to save. + } } } } diff --git a/src/main/scala/li/cil/oc/common/tileentity/Case.scala b/src/main/scala/li/cil/oc/common/tileentity/Case.scala index b71f7464c..dd26a205f 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/Case.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/Case.scala @@ -25,7 +25,12 @@ import net.minecraftforge.common.util.ForgeDirection import scala.collection.convert.WrapAsJava._ class Case(var tier: Int) extends traits.PowerAcceptor with traits.Computer with traits.Colored with internal.Case with DeviceInfo { - def this() = this(0) + def this() = { + this(0) + // If no tier was defined when constructing this case, then we don't yet know the inventory size + // this is set back to true when the nbt data is loaded + isSizeInventoryReady = false + } // Used on client side to check whether to render disk activity/network indicators. var lastFileSystemAccess = 0L @@ -78,6 +83,7 @@ class Case(var tier: Int) extends traits.PowerAcceptor with traits.Computer with tier = nbt.getByte(Settings.namespace + "tier") max 0 min 3 color = Color.byTier(tier) super.readFromNBTForServer(nbt) + isSizeInventoryReady = true } override def writeToNBTForServer(nbt: NBTTagCompound) { From 73c2eac5cf887db6d55f06f7ae602e191b84f4f8 Mon Sep 17 00:00:00 2001 From: payonel Date: Tue, 2 Jan 2018 23:49:32 -0800 Subject: [PATCH 3/4] correct merge for carpeted capacitor --- .../blockstates/carpetedCapacitor.json | 5 +++++ .../models/block/carpetedCapacitor.json | 8 ++++++++ .../models/item/carpetedCapacitor.json | 10 ++++++++++ ...tCapacitorTop.png => carpeted_capacitor_top.png} | Bin .../li/cil/oc/common/block/CarpetedCapacitor.scala | 11 +---------- .../oc/common/tileentity/CarpetedCapacitor.scala | 12 +++++------- 6 files changed, 29 insertions(+), 17 deletions(-) create mode 100644 src/main/resources/assets/opencomputers/blockstates/carpetedCapacitor.json create mode 100644 src/main/resources/assets/opencomputers/models/block/carpetedCapacitor.json create mode 100644 src/main/resources/assets/opencomputers/models/item/carpetedCapacitor.json rename src/main/resources/assets/opencomputers/textures/blocks/{CarpetCapacitorTop.png => carpeted_capacitor_top.png} (100%) diff --git a/src/main/resources/assets/opencomputers/blockstates/carpetedCapacitor.json b/src/main/resources/assets/opencomputers/blockstates/carpetedCapacitor.json new file mode 100644 index 000000000..69a93e964 --- /dev/null +++ b/src/main/resources/assets/opencomputers/blockstates/carpetedCapacitor.json @@ -0,0 +1,5 @@ +{ + "variants": { + "normal": { "model": "opencomputers:carpetedCapacitor" } + } +} diff --git a/src/main/resources/assets/opencomputers/models/block/carpetedCapacitor.json b/src/main/resources/assets/opencomputers/models/block/carpetedCapacitor.json new file mode 100644 index 000000000..2b8c02949 --- /dev/null +++ b/src/main/resources/assets/opencomputers/models/block/carpetedCapacitor.json @@ -0,0 +1,8 @@ +{ + "parent": "block/cube_bottom_top", + "textures": { + "bottom": "opencomputers:blocks/generic_top", + "top": "opencomputers:blocks/carpeted_capacitor_top", + "side": "opencomputers:blocks/capacitor_side" + } +} diff --git a/src/main/resources/assets/opencomputers/models/item/carpetedCapacitor.json b/src/main/resources/assets/opencomputers/models/item/carpetedCapacitor.json new file mode 100644 index 000000000..d0acc389d --- /dev/null +++ b/src/main/resources/assets/opencomputers/models/item/carpetedCapacitor.json @@ -0,0 +1,10 @@ +{ + "parent": "opencomputers:block/carpetedCapacitor", + "display": { + "thirdperson": { + "rotation": [ 10, -45, 170 ], + "translation": [ 0, 1.5, -2.75 ], + "scale": [ 0.375, 0.375, 0.375 ] + } + } +} diff --git a/src/main/resources/assets/opencomputers/textures/blocks/CarpetCapacitorTop.png b/src/main/resources/assets/opencomputers/textures/blocks/carpeted_capacitor_top.png similarity index 100% rename from src/main/resources/assets/opencomputers/textures/blocks/CarpetCapacitorTop.png rename to src/main/resources/assets/opencomputers/textures/blocks/carpeted_capacitor_top.png diff --git a/src/main/scala/li/cil/oc/common/block/CarpetedCapacitor.scala b/src/main/scala/li/cil/oc/common/block/CarpetedCapacitor.scala index 06d664b26..03108dce6 100644 --- a/src/main/scala/li/cil/oc/common/block/CarpetedCapacitor.scala +++ b/src/main/scala/li/cil/oc/common/block/CarpetedCapacitor.scala @@ -4,14 +4,5 @@ import li.cil.oc.common.tileentity import net.minecraft.world.World class CarpetedCapacitor extends Capacitor { - override def createTileEntity(world: World, metadata: Int) = new tileentity.CarpetedCapacitor() - - override protected def customTextures = Array( - None, - Some("CarpetCapacitorTop"), - Some("CapacitorSide"), - Some("CapacitorSide"), - Some("CapacitorSide"), - Some("CapacitorSide") - ) + override def createNewTileEntity(world: World, metadata: Int) = new tileentity.CarpetedCapacitor() } diff --git a/src/main/scala/li/cil/oc/common/tileentity/CarpetedCapacitor.scala b/src/main/scala/li/cil/oc/common/tileentity/CarpetedCapacitor.scala index e0db016cb..f07d209b5 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/CarpetedCapacitor.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/CarpetedCapacitor.scala @@ -8,13 +8,14 @@ import li.cil.oc.api.driver.DeviceInfo.DeviceClass import li.cil.oc.Settings import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.passive.{EntityOcelot, EntitySheep} -import net.minecraft.util.{AxisAlignedBB, DamageSource} -import net.minecraftforge.common.util.ForgeDirection +import net.minecraft.util.DamageSource +import net.minecraft.util.EnumFacing import scala.collection.convert.WrapAsJava._ import scala.collection.convert.WrapAsScala._ +import li.cil.oc.common.tileentity.traits.Tickable -class CarpetedCapacitor extends Capacitor { +class CarpetedCapacitor extends Capacitor with Tickable { private final lazy val deviceInfo = Map( DeviceAttribute.Class -> DeviceClass.Power, DeviceAttribute.Description -> "Battery", @@ -25,8 +26,6 @@ class CarpetedCapacitor extends Capacitor { override def getDeviceInfo: util.Map[String, String] = deviceInfo - override def canUpdate = true - private val rng = scala.util.Random private val chance: Double = Settings.get.carpetDamageChance private var nextChanceTime: Long = 0 @@ -54,7 +53,6 @@ class CarpetedCapacitor extends Capacitor { override def updateEntity() { if (node != null && (world.getTotalWorldTime + hashCode) % 20 == 0) { val entities = world.getEntitiesWithinAABB(classOf[EntityLivingBase], capacitorPowerBounds) - .map(_.asInstanceOf[EntityLivingBase]) .filter(entity => entity.isEntityAlive) .toSet val sheepPower = energyFromGroup(entities.filter(_.isInstanceOf[EntitySheep]), Settings.get.sheepPower) @@ -66,5 +64,5 @@ class CarpetedCapacitor extends Capacitor { } } - private def capacitorPowerBounds = position.offset(ForgeDirection.UP).bounds + private def capacitorPowerBounds = position.offset(EnumFacing.UP).bounds } From 47def83811710236b02ba3d8b78ee67d38d962e2 Mon Sep 17 00:00:00 2001 From: payonel Date: Fri, 5 Jan 2018 05:57:46 -0800 Subject: [PATCH 4/4] merge fixes for carpet capacitors --- .../assets/opencomputers/blockstates/carpetedCapacitor.json | 5 ----- .../assets/opencomputers/blockstates/carpetedcapacitor.json | 5 +++++ src/main/resources/assets/opencomputers/lang/en_US.lang | 2 +- .../block/{carpetedCapacitor.json => carpetedcapacitor.json} | 0 .../item/{carpetedCapacitor.json => carpetedcapacitor.json} | 2 +- .../resources/assets/opencomputers/recipes/default.recipes | 2 +- .../resources/assets/opencomputers/recipes/gregtech.recipes | 2 +- .../resources/assets/opencomputers/recipes/hardmode.recipes | 2 +- .../li/cil/oc/common/tileentity/CarpetedCapacitor.scala | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 src/main/resources/assets/opencomputers/blockstates/carpetedCapacitor.json create mode 100644 src/main/resources/assets/opencomputers/blockstates/carpetedcapacitor.json rename src/main/resources/assets/opencomputers/models/block/{carpetedCapacitor.json => carpetedcapacitor.json} (100%) rename src/main/resources/assets/opencomputers/models/item/{carpetedCapacitor.json => carpetedcapacitor.json} (78%) diff --git a/src/main/resources/assets/opencomputers/blockstates/carpetedCapacitor.json b/src/main/resources/assets/opencomputers/blockstates/carpetedCapacitor.json deleted file mode 100644 index 69a93e964..000000000 --- a/src/main/resources/assets/opencomputers/blockstates/carpetedCapacitor.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "variants": { - "normal": { "model": "opencomputers:carpetedCapacitor" } - } -} diff --git a/src/main/resources/assets/opencomputers/blockstates/carpetedcapacitor.json b/src/main/resources/assets/opencomputers/blockstates/carpetedcapacitor.json new file mode 100644 index 000000000..f6c92cb33 --- /dev/null +++ b/src/main/resources/assets/opencomputers/blockstates/carpetedcapacitor.json @@ -0,0 +1,5 @@ +{ + "variants": { + "normal": { "model": "opencomputers:carpetedcapacitor" } + } +} diff --git a/src/main/resources/assets/opencomputers/lang/en_US.lang b/src/main/resources/assets/opencomputers/lang/en_US.lang index 52998583d..38baa2d34 100644 --- a/src/main/resources/assets/opencomputers/lang/en_US.lang +++ b/src/main/resources/assets/opencomputers/lang/en_US.lang @@ -7,7 +7,7 @@ tile.oc.adapter.name=Adapter tile.oc.assembler.name=Electronics Assembler tile.oc.cable.name=Cable tile.oc.capacitor.name=Capacitor -tile.oc.carpetedCapacitor.name=Carpeted Capacitor +tile.oc.carpetedcapacitor.name=Carpeted Capacitor tile.oc.case1.name=Computer Case (Tier 1) tile.oc.case2.name=Computer Case (Tier 2) tile.oc.case3.name=Computer Case (Tier 3) diff --git a/src/main/resources/assets/opencomputers/models/block/carpetedCapacitor.json b/src/main/resources/assets/opencomputers/models/block/carpetedcapacitor.json similarity index 100% rename from src/main/resources/assets/opencomputers/models/block/carpetedCapacitor.json rename to src/main/resources/assets/opencomputers/models/block/carpetedcapacitor.json diff --git a/src/main/resources/assets/opencomputers/models/item/carpetedCapacitor.json b/src/main/resources/assets/opencomputers/models/item/carpetedcapacitor.json similarity index 78% rename from src/main/resources/assets/opencomputers/models/item/carpetedCapacitor.json rename to src/main/resources/assets/opencomputers/models/item/carpetedcapacitor.json index d0acc389d..a717606ce 100644 --- a/src/main/resources/assets/opencomputers/models/item/carpetedCapacitor.json +++ b/src/main/resources/assets/opencomputers/models/item/carpetedcapacitor.json @@ -1,5 +1,5 @@ { - "parent": "opencomputers:block/carpetedCapacitor", + "parent": "opencomputers:block/carpetedcapacitor", "display": { "thirdperson": { "rotation": [ 10, -45, 170 ], diff --git a/src/main/resources/assets/opencomputers/recipes/default.recipes b/src/main/resources/assets/opencomputers/recipes/default.recipes index 93233a6a2..e0b41c1f0 100644 --- a/src/main/resources/assets/opencomputers/recipes/default.recipes +++ b/src/main/resources/assets/opencomputers/recipes/default.recipes @@ -564,7 +564,7 @@ luaBios { type: shapeless input: ["oc:eeprom", "oc:manual"] } -carpetedCapacitor { +carpetedcapacitor { type: shapeless input: [carpet, "oc:capacitor"] } diff --git a/src/main/resources/assets/opencomputers/recipes/gregtech.recipes b/src/main/resources/assets/opencomputers/recipes/gregtech.recipes index 0fb06193a..1c3a45134 100644 --- a/src/main/resources/assets/opencomputers/recipes/gregtech.recipes +++ b/src/main/resources/assets/opencomputers/recipes/gregtech.recipes @@ -271,7 +271,7 @@ cable { time: 64 output: 8 } -carpetedCapacitor { +carpetedcapacitor { type: shapeless input: [carpet, "oc:capacitor"] } diff --git a/src/main/resources/assets/opencomputers/recipes/hardmode.recipes b/src/main/resources/assets/opencomputers/recipes/hardmode.recipes index bc3f003c9..14cc0646a 100644 --- a/src/main/resources/assets/opencomputers/recipes/hardmode.recipes +++ b/src/main/resources/assets/opencomputers/recipes/hardmode.recipes @@ -316,7 +316,7 @@ cable { ["", iron_nugget, ""]] output: 4 } -carpetedCapacitor { +carpetedcapacitor { type: shapeless input: [carpet, "oc:capacitor"] } diff --git a/src/main/scala/li/cil/oc/common/tileentity/CarpetedCapacitor.scala b/src/main/scala/li/cil/oc/common/tileentity/CarpetedCapacitor.scala index 82895897e..b355dc9d9 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/CarpetedCapacitor.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/CarpetedCapacitor.scala @@ -26,7 +26,7 @@ class CarpetedCapacitor extends Capacitor with Tickable { override def getDeviceInfo: util.Map[String, String] = deviceInfo - private def _world: net.minecraft.world.World = asInstanceOf[Capacitor].world + private def _world: net.minecraft.world.World = getWorld private val rng = scala.util.Random private val chance: Double = Settings.get.carpetDamageChance private var nextChanceTime: Long = 0