From d967c23fce81d46fa59813c7d9ffc8a1f9f8e90a Mon Sep 17 00:00:00 2001 From: Craig Parton Date: Fri, 6 Nov 2015 21:54:18 -0500 Subject: [PATCH 01/34] Update ItemArcaneCompendium.java --- src/main/java/am2/items/ItemArcaneCompendium.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/am2/items/ItemArcaneCompendium.java b/src/main/java/am2/items/ItemArcaneCompendium.java index 43f5b4b85..8f6d50e03 100644 --- a/src/main/java/am2/items/ItemArcaneCompendium.java +++ b/src/main/java/am2/items/ItemArcaneCompendium.java @@ -24,4 +24,9 @@ public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int return false; } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister){ + this.itemIcon = ResourceManager.RegisterTexture("arcanecompendium", par1IconRegister); + } } From d66ea48393ffe5e2203762023db5875c538462b6 Mon Sep 17 00:00:00 2001 From: BiffiMaps Date: Sun, 8 Nov 2015 18:05:49 +0300 Subject: [PATCH 02/34] Expanded ru_RU.lang --- .../assets/arsmagica2/lang/ru_RU.lang | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/main/resources/assets/arsmagica2/lang/ru_RU.lang b/src/main/resources/assets/arsmagica2/lang/ru_RU.lang index bb418b460..31bd897bd 100644 --- a/src/main/resources/assets/arsmagica2/lang/ru_RU.lang +++ b/src/main/resources/assets/arsmagica2/lang/ru_RU.lang @@ -374,7 +374,7 @@ am2.spell.targetnonsolid=Цель: Нетвёрдые блоки am2.spell.velocityadded=Добавление скорости am2.spell.affinitygains=Сродство даёт усиление -am2.spell.augmentedcasting=Augmented Casting +am2.spell.augmentedcasting=Улучшенное литьё am2.spell.extrasummon=Дополнительный призыв am2.spell.magebandi=Поиск маны I am2.spell.magebandii=Поиск маны II @@ -604,56 +604,56 @@ am2.npc.partyrefuse=Вы должны стать более сильным, пр #affinity effect descriptions ##air -am2.affinity.agile=Agile -am2.affinity.lightasafeather=Light as a Feather +am2.affinity.agile=Проворство +am2.affinity.lightasafeather=Перо это свет ##arcane -am2.affinity.clearcaster=Clearcaster -am2.affinity.magicweakness=Magic Weakness -am2.affinity.onewithmagic=Magical Focus +am2.affinity.clearcaster=Чистая аура +am2.affinity.magicweakness=Магическая слабость +am2.affinity.onewithmagic=Сфокусирование магии ##earth -am2.affinity.solidbones=Solid Bones -am2.affinity.stoneskin=Stone Skin +am2.affinity.solidbones=Твёрдые Кости +am2.affinity.stoneskin=Каменная Кожа ##ender -am2.affinity.darkvision=Darkvision -am2.affinity.poisonresistance=Resistant to Poison -am2.affinity.sunlightweakness=Weakness to Sunlight -am2.affinity.waterweakness=Weakness to Water +am2.affinity.darkvision=Темновидиние +am2.affinity.poisonresistance=Устойчивость к яду +am2.affinity.sunlightweakness=Устойчивость к солнечному свету +am2.affinity.waterweakness=Устойчивость к воде ##fire -am2.affinity.firepunch=Fire Punch -am2.affinity.fireresistance=Resistant to Fire -am2.affinity.waterweakness=Weakness to Water +am2.affinity.firepunch=Огненный шлепок +am2.affinity.fireresistance=Слабость к Огню +am2.affinity.waterweakness=Слабость к воде ##ice -am2.affinity.coldblooded=Cold Blooded -am2.affinity.lavafreeze=Frozen Footsteps (Lava) -am2.affinity.waterfreeze=Frozen Footsteps (Water) +am2.affinity.coldblooded=Окровлённый холод +am2.affinity.lavafreeze=Замороженные Шаги (Лава) +am2.affinity.waterfreeze=Замороженные шаги (Вода) ##life -am2.affinity.fasthealing=Fast Healing -am2.affinity.pacifist=Pacifist +am2.affinity.fasthealing=Быстрое лечение +am2.affinity.pacifist=Пацифист ##water -am2.affinity.antiendermen=Endermen-Repellant -am2.affinity.expandedlungs=Expanded Lungs -am2.affinity.fireweakness=Fire Weakness -am2.affinity.fluidity=Fluidity -am2.affinity.swiftswim=Swift Swimmer +am2.affinity.antiendermen=Эндерман-откидывание +am2.affinity.expandedlungs=Расширенная лёгкость +am2.affinity.fireweakness=Слабость к огню +am2.affinity.fluidity=Текучесть +am2.affinity.swiftswim=Быстрое лето ##nature -am2.affinity.harvester=Harvester -am2.affinity.photosynthesis=Photosynthesis -am2.affinity.rooted=Rooted -am2.affinity.thorns=Thorns Aura +am2.affinity.harvester=Комбайн +am2.affinity.photosynthesis=Фотосинтез +am2.affinity.rooted=Коренноый +am2.affinity.thorns=Шыпастая аура ##lightning -am2.affinity.fulmination=Fulmination -am2.affinity.reflexes=Lightning Reflexes -am2.affinity.shortcircuit=Short Circuit -am2.affinity.thunderpunch=Thunderpunch +am2.affinity.fulmination=Инициированный врзыр +am2.affinity.reflexes=Рефлекты света +am2.affinity.shortcircuit=Короткая схема +am2.affinity.thunderpunch=Громовой шлепок #achievements From a3d802b6f0926f21dbbc5eed16b4b0bf058bf987 Mon Sep 17 00:00:00 2001 From: claybiockiller Date: Mon, 16 Nov 2015 15:05:30 +0800 Subject: [PATCH 03/34] Update zh_CN.lang --- .../assets/arsmagica2/lang/zh_CN.lang | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/resources/assets/arsmagica2/lang/zh_CN.lang b/src/main/resources/assets/arsmagica2/lang/zh_CN.lang index f83e72017..38a706dd1 100644 --- a/src/main/resources/assets/arsmagica2/lang/zh_CN.lang +++ b/src/main/resources/assets/arsmagica2/lang/zh_CN.lang @@ -6,6 +6,7 @@ item.arsmagica2:FlickerFocusPrefix=闪烁核心: %s item.arsmagica2:FlickerOperatorButchery.name=屠宰场 item.arsmagica2:FlickerOperatorContainment.name=蕴含 item.arsmagica2:FlickerOperatorFelledOak.name=倒下的橡木 +item.arsmagica2:FlickerOperatorFishing.name=鱼满舱 item.arsmagica2:FlickerOperatorFlatLands.name=大地平坦 item.arsmagica2:FlickerOperatorGentleRains.name=和风细雨 item.arsmagica2:FlickerOperatorInterdiction.name=禁制 @@ -74,6 +75,9 @@ item.arsmagica2:helmet_mage.name=法师头巾 item.arsmagica2:highEssenceCore.name=高级源质核心 item.arsmagica2:iceEssence.name=寒冰源质 item.arsmagica2:infinityOrb.name=无限之球 +item.arsmagica2:inscup_1.name=符文拓印台1阶升级 +item.arsmagica2:inscup_2.name=符文拓印台2阶升级 +item.arsmagica2:inscup_3.name=符文拓印台3阶升级 item.arsmagica2:item_focus.name=物品核心 item.arsmagica2:keystone.name=楔石 item.arsmagica2:keystoneDoor.name=楔石之门 @@ -87,7 +91,7 @@ item.arsmagica2:lightBlueRune.name=浅蓝色符文 item.arsmagica2:lightGrayRune.name=浅灰色符文 item.arsmagica2:lightningEssence.name=雷霆源质 item.arsmagica2:lightningcharm.name=§6闪电魔咒§f -item.arsmagica2:limeRune.name=柠檬色符文 +item.arsmagica2:limeRune.name=黄绿色符文 item.arsmagica2:liquidEssenceBucket.name=液态源质桶 item.arsmagica2:magentaRune.name=品红色符文 item.arsmagica2:magic_broom.name=魔法扫帚 @@ -95,6 +99,7 @@ item.arsmagica2:magitechGoggles.name=奥术护目镜 item.arsmagica2:manaScepter.name=魔杖 item.arsmagica2:mana_boost_potion.name=蕴魔源质药水 item.arsmagica2:mana_cake.name=魔力蛋糕 +item.arsmagica2:mana_martini.name=魔力马天尼 item.arsmagica2:mana_potion_epic.name=史诗魔力药水 item.arsmagica2:mana_potion_greater.name=卓越魔力药水 item.arsmagica2:mana_potion_legendary.name=传奇魔力药水 @@ -130,6 +135,7 @@ item.arsmagica2:sigil_naturesbounty=自然的馈赠 item.arsmagica2:sigil_packedearth=壅塞大地 item.arsmagica2:sigil_progeny=后裔 item.arsmagica2:spellBook.name=法术书 +item.arsmagica2:spellSealedDoor.name=咒封之门 item.arsmagica2:spell_parchment.name=法术卷轴 item.arsmagica2:spell_staff_journeyman.name=学徒魔杖 item.arsmagica2:spell_staff_magitech.name=奥术魔杖 @@ -161,19 +167,21 @@ tile.arsmagica2:blockastralbarrier.name=星界屏障 tile.arsmagica2:blockcaster.name=施术台 tile.arsmagica2:blockkeystonerecepticle.name=楔石插槽 tile.arsmagica2:blockseerstone.name=占卜之眼 -tile.arsmagica2:blue_orchid.name=万代兰 tile.arsmagica2:brokenLink.name=破损能量链接 tile.arsmagica2:calefactor.name=魔力炉 tile.arsmagica2:candle.name=守护蜡烛 tile.arsmagica2:casterRune.name=施术台符文 tile.arsmagica2:celestialprism.name=仙域棱镜 +tile.arsmagica2:cerublossom.name=天蓝花 tile.arsmagica2:crystalMarker.cm_export.name=导出水晶 +tile.arsmagica2:crystalMarker.cm_final.name=终末导出水晶 tile.arsmagica2:crystalMarker.cm_import.name=导入水晶 tile.arsmagica2:crystalMarker.cm_likeExport.name=伪装导出水晶 tile.arsmagica2:crystalMarker.cm_regulateExport.name=调校导出水晶 tile.arsmagica2:crystalMarker.cm_regulateMulti.name=调校双向水晶 tile.arsmagica2:crystalMarker.cm_setExport.name=设置导出水晶 tile.arsmagica2:crystalMarker.cm_setImport.name=设置导入水晶 +tile.arsmagica2:crystalMarker.cm_spellExport.name=法术导出水晶 tile.arsmagica2:crystalpillar.name=水晶柱 tile.arsmagica2:desert_nova.name=沙漠新星 tile.arsmagica2:essence_refiner.name=源质提炼机 @@ -187,9 +195,12 @@ tile.arsmagica2:illusionBlock.nobarrier.name=天域幻象方块 tile.arsmagica2:inertSpawner.name=惰性刷怪笼 tile.arsmagica2:inscriptionTable.name=符文拓印台 tile.arsmagica2:iron_inlay.name=黑铁镶嵌物 +tile.arsmagica2:keystoneDoor.name=楔石门 tile.arsmagica2:keystoneTrapdoor.name=楔石陷阱门 tile.arsmagica2:keystonechest.name=楔石箱子 tile.arsmagica2:lectern.name=讲坛 +tile.arsmagica2:liquidEssence.name=液态以金 +tile.arsmagica2:magetorch.name=魔导之光 tile.arsmagica2:magicWall.name=魔力屏障 tile.arsmagica2:magic_sigil.name=徽记底座 tile.arsmagica2:magiciansWorkbench.name=巫师工作台 @@ -206,6 +217,7 @@ tile.arsmagica2:ores.6.name=温特姆方块 tile.arsmagica2:ores.7.name=蓝晶石方块 tile.arsmagica2:ores.8.name=太阳石方块 tile.arsmagica2:ores.9.name=精灵石矿石 +tile.arsmagica2:otherworld_aura.name=异世界灵气 tile.arsmagica2:particleEmitter.name=粒子效果发生器 tile.arsmagica2:planksWitchwood.name=巫魂树木板 tile.arsmagica2:redstone_inlay.name=红石镶嵌物 @@ -223,6 +235,9 @@ tile.arsmagica2:witchwoodleaves.name=巫魂树树叶 tile.arsmagica2:witchwoodlog.name=巫魂树原木 tile.arsmagica2:wizardchalk.name=巫师粉笔符文 +#fluids +fluid.liquidEssence=液态以金 + #entities entity.arsmagica2.BattleChicken.name=战斗鸡 entity.arsmagica2.BossAirGuardian.name=风之守卫者 @@ -236,6 +251,7 @@ entity.arsmagica2.BossNatureGuardian.name=自然守卫者 entity.arsmagica2.BossTowerGuardian.name=法师塔守卫者 entity.arsmagica2.BossWaterGuardian.name=水之守卫者 entity.arsmagica2.BossWinterGuardian.name=冬之守卫者 +entity.arsmagica2.DaBroom.name=魔法扫帚 entity.arsmagica2.EarthElemental.name=地之元素 entity.arsmagica2.Flicker.name=闪烁妖精 entity.arsmagica2.HellCow.name=深渊牛 @@ -257,7 +273,7 @@ am2.spell.validate.compMiss=至少需要一种复合物作为施法材料. am2.spell.validate.principum=为正确施术是否需要在其后添加规则形态以及目标形态.参阅巫师宝典以获得详细信息. am2.spell.validate.terminus=是否在其后添加的终端形态或者任何其他形态不会被执行.参阅巫师宝典以获得详细信息. -am2.spell.aoe=AOE法术 +am2.spell.aoe=范围法术 am2.spell.beam=束状法术 am2.spell.binding=具现化法术 am2.spell.chain=链状法术 @@ -385,6 +401,7 @@ am2.spell.spellmotion=施术动作 #tooltips am2.tooltip.air_sled=§3飘逸地翱翔天际...§f +am2.tooltip.approError=恢复方块时发生了错误.这个法术似乎来自旧版本. The stored block has been cleared to prevent a crash, and the spell should work moving forward. Sorry! am2.tooltip.arcanespellbook=§3获得老巫师的力量.§f am2.tooltip.armorlevel=护甲XP等级:%d am2.tooltip.armorxp=灌魔经验:%d @@ -417,7 +434,7 @@ am2.tooltip.hungerup=饱腹回复 am2.tooltip.infOrbBlue=你获得了一个§9蓝色§f技能点! am2.tooltip.infOrbFail0=你全神贯注盯着球看,结果成了斗鸡眼. am2.tooltip.infOrbFail1=僵尸吃掉了你的脑子. -am2.tooltip.infOrbFail2=我擦! +am2.tooltip.infOrbFail2=就只知道做爱 am2.tooltip.infOrbFail3=我认为我这几周白干了. am2.tooltip.infOrbFail4=我的理性和理智已经飞去鲁尼外奥了. am2.tooltip.infOrbFail5=我以披萨之神的名义,CHARGE! From 0a22d6637210bc8d6de62ad30adf760cf1033fa9 Mon Sep 17 00:00:00 2001 From: claybiockiller Date: Mon, 16 Nov 2015 17:30:45 +0800 Subject: [PATCH 04/34] Update zh_CN.lang --- .../assets/arsmagica2/lang/zh_CN.lang | 75 +++++++++++++------ 1 file changed, 53 insertions(+), 22 deletions(-) diff --git a/src/main/resources/assets/arsmagica2/lang/zh_CN.lang b/src/main/resources/assets/arsmagica2/lang/zh_CN.lang index 38a706dd1..f5bf30004 100644 --- a/src/main/resources/assets/arsmagica2/lang/zh_CN.lang +++ b/src/main/resources/assets/arsmagica2/lang/zh_CN.lang @@ -172,7 +172,7 @@ tile.arsmagica2:calefactor.name=魔力炉 tile.arsmagica2:candle.name=守护蜡烛 tile.arsmagica2:casterRune.name=施术台符文 tile.arsmagica2:celestialprism.name=仙域棱镜 -tile.arsmagica2:cerublossom.name=天蓝花 +tile.arsmagica2:cerublossom.name=万代兰 tile.arsmagica2:crystalMarker.cm_export.name=导出水晶 tile.arsmagica2:crystalMarker.cm_final.name=终末导出水晶 tile.arsmagica2:crystalMarker.cm_import.name=导入水晶 @@ -199,7 +199,7 @@ tile.arsmagica2:keystoneDoor.name=楔石门 tile.arsmagica2:keystoneTrapdoor.name=楔石陷阱门 tile.arsmagica2:keystonechest.name=楔石箱子 tile.arsmagica2:lectern.name=讲坛 -tile.arsmagica2:liquidEssence.name=液态以金 +tile.arsmagica2:liquidEssence.name=液态乙金 tile.arsmagica2:magetorch.name=魔导之光 tile.arsmagica2:magicWall.name=魔力屏障 tile.arsmagica2:magic_sigil.name=徽记底座 @@ -236,7 +236,7 @@ tile.arsmagica2:witchwoodlog.name=巫魂树原木 tile.arsmagica2:wizardchalk.name=巫师粉笔符文 #fluids -fluid.liquidEssence=液态以金 +fluid.liquidEssence=液态乙金 #entities entity.arsmagica2.BattleChicken.name=战斗鸡 @@ -401,7 +401,7 @@ am2.spell.spellmotion=施术动作 #tooltips am2.tooltip.air_sled=§3飘逸地翱翔天际...§f -am2.tooltip.approError=恢复方块时发生了错误.这个法术似乎来自旧版本. The stored block has been cleared to prevent a crash, and the spell should work moving forward. Sorry! +am2.tooltip.approError=恢复方块时发生了错误.这个法术似乎来自旧版本.储存的方块会被清除以防止崩溃,且法术应当继续进行.抱歉! am2.tooltip.arcanespellbook=§3获得老巫师的力量.§f am2.tooltip.armorlevel=护甲XP等级:%d am2.tooltip.armorxp=灌魔经验:%d @@ -410,7 +410,11 @@ am2.tooltip.candlecantplace=你不能放置调谐好的蜡烛. am2.tooltip.cantSummonSelf=你不能使用仪式召唤自己. am2.tooltip.charge=充能 am2.tooltip.clearKey=在破坏方块前先清除楔石组合! +am2.tooltip.compEntryNotFound=摘要词条(提示符: %s)未找到 am2.tooltip.containedXP=包含经验 %d +am2.tooltip.det_eth=探测到%s%s§f乙金: %s +am2.tooltip.diffDimMark=你的标记在另一个世界 +am2.tooltip.disconnectPower=所有能源到此方块的连接均已中断. am2.tooltip.dispel=驱散 am2.tooltip.dr_drn=窒息伤害抵御 am2.tooltip.dr_exp=爆炸伤害抵御 @@ -422,7 +426,7 @@ am2.tooltip.dr_mage=魔法伤害抵御 am2.tooltip.dr_phy=物理伤害抵御 am2.tooltip.earth_armor=§3像大地一样弹乎乎的.§f am2.tooltip.empty=空 -am2.tooltip.ender_boots=§3我拒绝汝之现实,以我自己的来代替.!§f +am2.tooltip.ender_boots=§3吾欲拒汝之实感,代之以吾自所感!§f am2.tooltip.fallprot=跌落防护 am2.tooltip.fire_ears=§3拥抱火焰.§f am2.tooltip.fireprot=灼伤防护 @@ -433,15 +437,15 @@ am2.tooltip.highjump=跳跃加成 am2.tooltip.hungerup=饱腹回复 am2.tooltip.infOrbBlue=你获得了一个§9蓝色§f技能点! am2.tooltip.infOrbFail0=你全神贯注盯着球看,结果成了斗鸡眼. -am2.tooltip.infOrbFail1=僵尸吃掉了你的脑子. -am2.tooltip.infOrbFail2=就只知道做爱 -am2.tooltip.infOrbFail3=我认为我这几周白干了. -am2.tooltip.infOrbFail4=我的理性和理智已经飞去鲁尼外奥了. -am2.tooltip.infOrbFail5=我以披萨之神的名义,CHARGE! -am2.tooltip.infOrbFail6=做这些仅仅是为了耍帅? +am2.tooltip.infOrbFail1=你不再感觉到你的头脑. +am2.tooltip.infOrbFail2=浑身难受. +am2.tooltip.infOrbFail3=我认为我这几周成了废物. +am2.tooltip.infOrbFail4=我们已经离开了利森(理性)街和森尼提(理智)大道路口.下一站,卢尼维尔. +am2.tooltip.infOrbFail5=我以披萨之神的名义,充能! +am2.tooltip.infOrbFail6=做这些仅仅是为了堆辞藻? am2.tooltip.infOrbFail7=华夫饼就像沾了甜酱的煎饼. -am2.tooltip.infOrbFail8=你还敢不敢说你看到了啥. -am2.tooltip.infOrbFail9=你深信有什么重要人物会接见你. +am2.tooltip.infOrbFail8=你不再会说你看到了啥. +am2.tooltip.infOrbFail9=你深信有一辆南瓜车会找你. am2.tooltip.infOrbGreen=你获得了一个§2绿色§f 技能点! am2.tooltip.infOrbRed=你获得了一个§4红色§f 技能点! am2.tooltip.journalOwner2=日记之主:%s @@ -459,9 +463,13 @@ am2.tooltip.mn_reg=魔力回复加成 am2.tooltip.mwLock=左SHIFT+右击锁定合成表 am2.tooltip.mwUnlock=左SHIFT+右击解锁合成表 am2.tooltip.nature_scythe=§3我杀死了你的主人,臣服于我吧!§f +am2.tooltip.noKeyPresent=这里没有楔石锁. +am2.tooltip.noMark=没有可供唤回的标记. am2.tooltip.noMatchingGate=无法找到匹配的门户. am2.tooltip.noMatchingPlayer=无法找到匹配玩家. +am2.tooltip.noMoreSummons=你不能再继续召唤. am2.tooltip.noPathFound=旋转节点间未发现路径. +am2.tooltip.noPriIn=输入标记不能登记优先级. am2.tooltip.noSupportedPowertypes=目标所需类型的能量节点无法供应. am2.tooltip.nodePairToSelf=你无法使节点同自己配对! am2.tooltip.nodesTooFar=节点相距过远,无法配对! @@ -473,11 +481,13 @@ am2.tooltip.pctFull=已充满%.2f百分比 am2.tooltip.phyEss= §b%s源质 am2.tooltip.placeBlockSpell=放置方块将会放置: %s am2.tooltip.pp_ore=探明矿藏(消耗守护蜡烛) +am2.tooltip.priSet=优先级已设为%s. +am2.tooltip.priority=优先级: %s am2.tooltip.recoil=召回 am2.tooltip.regen=为AM2 beta测试人员增加法力回复速度 am2.tooltip.run_spd=奔速加成 am2.tooltip.runes=激活符文 -am2.tooltip.rupees=不差钱! +am2.tooltip.rupees=不差卢比! am2.tooltip.shiftForAffinity=按住左shift详细查看亲和力 am2.tooltip.shiftForDetails=按住左shift键以查看细节. am2.tooltip.soulbnd=灵魂绑定 @@ -486,12 +496,17 @@ am2.tooltip.success=配对成功! am2.tooltip.swimspd=泳速加成 am2.tooltip.tc_nrv=神秘视野(需安装神秘时代) am2.tooltip.unattuned=未调谐 +am2.tooltip.unfinishedSpellRecipe=未完成法术配方. +am2.tooltip.unlockSuccess=词条解锁. am2.tooltip.unowned=日记的页面为空白. am2.tooltip.upToDate=你的魔法艺术2版本已升级. -am2.tooltip.updateAvailable=模组升级可用.左击前往下载地址. +am2.tooltip.updateAvailable=模组升级可用.左击前往下载地址.右击阅读升级日志. am2.tooltip.uses=剩余次数 am2.tooltip.water_orbs=§3水乃你盆友.§f am2.tooltip.winter_arm=§3冷酷到底.§f +am2.tooltip.wrongKeystoneBreak=你没有破坏此方块应使用的楔石. +am2.tooltip.wrongKeystoneUse=你没有使用此方块应使用的楔石. +am2.tooltip.wrongWrenchMode=扳手未设定到正确的模式. am2.tooltip.wtrbrth=水下呼吸 am2.tooltip.wtrwalk=水上行走 @@ -506,7 +521,7 @@ am2.gui.action=执行 am2.gui.affinity=亲和力UI am2.gui.airAffinity=风系 am2.gui.all=全部 -am2.gui.alpha=透明通道 +am2.gui.alpha=阿尔法 am2.gui.arcaneAffinity=奥术 am2.gui.armorUI=显示护甲状态 am2.gui.back=返回 @@ -537,6 +552,10 @@ am2.gui.done=完成 am2.gui.earthAffinity=地系 am2.gui.enderAffinity=末影 am2.gui.fireAffinity=火系 +am2.gui.flicker_doesntneedpower=不需要乙金.一旦提供会消耗. +am2.gui.flicker_needspower=需要乙金以释放. +am2.gui.flicker_optime=施法时间: %s 秒 +am2.gui.flicker_powerperop=乙金/每施法: %s am2.gui.green=绿 am2.gui.greenPoint=绿色技能点 am2.gui.gridInUse1=可用合成网格均被占用. @@ -604,12 +623,17 @@ am2.gui.xpBar=经验条 am2.gui.yes=是 #death messages -am2.death.backfire=%s's法术失灵. -am2.death.fire=%s被火烤焦了. -am2.death.frost=%s冻成了冰块. -am2.death.lightning=%s触电身亡. -am2.death.wind=%s被风吹走了. -am2.death.wtfboom=%s狠狠撞上了仙人掌,又被卷入了岩浆湖中. +death.attack.am2.backfire.player=%1$s在与%2$s战斗时法术失灵 +death.attack.am2.backfire==%s的法术失灵. +death.attack.am2.darkNexus.player=%1$s在与%2$s战斗时生命力耗竭 +death.attack.am2.darkNexus=%s的生命力耗竭 +death.attack.am2.fire=%1$s走入火中因为%2$s +death.attack.am2.frost=%1$s被%2$s冻结了 +death.attack.am2.holy=%1$s看见了%2$s的真正光芒并当场解体 +death.attack.am2.lightning=%1$s被%2$s电击 +death.attack.am2.wind=%1$s被%2$s吹走了 +death.attack.am2.wtfboom.player=%1$s因为%2$s狠狠撞上了仙人掌,又被卷入了岩浆湖中 +death.attack.am2.wtfboom=%s狠狠撞上了仙人掌,又被卷入了岩浆湖中. #npc messages am2.npc.nopartyskill=我认识你吗? @@ -635,6 +659,7 @@ am2.affinity.stoneskin=石肤 ##ender am2.affinity.darkvision=夜视 +am2.affinity.phasing=相位化 am2.affinity.poisonresistance=抗毒 am2.affinity.sunlightweakness=惧光 am2.affinity.waterweakness=畏水 @@ -673,7 +698,13 @@ am2.affinity.reflexes=闪电反应 am2.affinity.shortcircuit=短路 am2.affinity.thunderpunch=雷拳 +#abilities +am2.affinity.enderTPFailed=不不不不不!!!! #achievements achievement.compendiumData=新条目解锁 achievement.componentUnlock=发现法术组件 + +Epic Mana Restoration.postfix=史诗魔力药水 +Greater Mana Restoration.postfix=卓越魔力药水 +Legendary Mana Restoration.postfix=传奇魔力药水 From beca3d85d071b1ebb23b215625565bec0946b3b8 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Fri, 20 Nov 2015 18:26:38 +0300 Subject: [PATCH 05/34] Fix PR #1 --- src/main/java/am2/items/ItemArcaneCompendium.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/am2/items/ItemArcaneCompendium.java b/src/main/java/am2/items/ItemArcaneCompendium.java index 43f5b4b85..54b19b510 100644 --- a/src/main/java/am2/items/ItemArcaneCompendium.java +++ b/src/main/java/am2/items/ItemArcaneCompendium.java @@ -4,6 +4,12 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import am2.texture.ResourceManager; public class ItemArcaneCompendium extends ArsMagicaItem{ @@ -24,4 +30,9 @@ public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int return false; } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister){ + this.itemIcon = ResourceManager.RegisterTexture("arcanecompendium", par1IconRegister); + } } From 903ebd3773575690bdc800771c2395542c07a2e2 Mon Sep 17 00:00:00 2001 From: Craig Parton Date: Fri, 20 Nov 2015 11:59:55 -0500 Subject: [PATCH 06/34] Update ItemArcaneCompendium.java --- src/main/java/am2/items/ItemArcaneCompendium.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/am2/items/ItemArcaneCompendium.java b/src/main/java/am2/items/ItemArcaneCompendium.java index 8f6d50e03..73273e59b 100644 --- a/src/main/java/am2/items/ItemArcaneCompendium.java +++ b/src/main/java/am2/items/ItemArcaneCompendium.java @@ -1,6 +1,10 @@ package am2.items; import am2.guis.AMGuiHelper; +import am2.texture.ResourceManager; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; From 120a8673b562039bc30ffd6ad26d5a9fa10f74d0 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sat, 28 Nov 2015 00:34:02 +0100 Subject: [PATCH 07/34] Optimized random number generation Reuse world RNG whenever possible, thus saving CPU load from recreating Random instances --- src/main/java/am2/AMEventHandler.java | 25 +++++++----- .../java/am2/affinity/AffinityHelper.java | 18 ++++----- .../am2/blocks/BlockArcaneReconstructor.java | 18 ++++----- .../java/am2/blocks/BlockArmorInfuser.java | 15 ++++--- .../java/am2/blocks/BlockAstralBarrier.java | 15 ++++--- src/main/java/am2/blocks/BlockCalefactor.java | 15 ++++--- .../am2/blocks/BlockEssenceGenerator.java | 15 ++++--- .../java/am2/blocks/BlockEssenceRefiner.java | 16 ++++---- .../java/am2/blocks/BlockFlickerHabitat.java | 13 +++---- .../java/am2/blocks/BlockInertSpawner.java | 13 +++---- .../am2/blocks/BlockInscriptionTable.java | 15 ++++--- .../java/am2/blocks/BlockKeystoneChest.java | 15 ++++--- src/main/java/am2/blocks/BlockLectern.java | 26 ++++++------- src/main/java/am2/blocks/BlockMageLight.java | 4 +- .../am2/blocks/BlockMagiciansWorkbench.java | 27 +++++++------ .../java/am2/blocks/BlockManaBattery.java | 13 +++---- src/main/java/am2/blocks/BlockSeerStone.java | 15 ++++--- .../java/am2/blocks/BlockSpellSealedDoor.java | 16 ++++---- src/main/java/am2/blocks/BlockSummoner.java | 16 ++++---- src/main/java/am2/blocks/IllusionBlock.java | 15 +++---- .../TileEntityArcaneReconstructor.java | 11 ++---- .../tileentities/TileEntityAstralBarrier.java | 8 ++-- .../tileentities/TileEntityCalefactor.java | 8 ++-- .../TileEntityEssenceConduit.java | 13 +++---- .../TileEntityFlickerHabitat.java | 5 +-- .../TileEntityInscriptionTable.java | 10 ++--- .../TileEntityKeystoneRecepticle.java | 2 - .../tileentities/TileEntityLectern.java | 10 ++--- .../TileEntityParticleEmitter.java | 16 ++++---- .../tileentities/TileEntitySeerStone.java | 2 +- .../am2/bosses/ai/EntityAIChaosWaterBolt.java | 4 +- src/main/java/am2/buffs/BuffEffect.java | 2 - .../am2/buffs/BuffEffectRegeneration.java | 7 +++- src/main/java/am2/commands/Explosions.java | 5 +-- .../entities/ai/EntityAIManaDrainBolt.java | 10 +++-- src/main/java/am2/guis/AM2FontRenderer.java | 2 +- src/main/java/am2/guis/AMGuiHelper.java | 3 +- .../am2/illeffect/IllEffectDrainMana.java | 2 - .../java/am2/illeffect/IllEffectSpark.java | 3 +- .../am2/illeffect/IllEffectSparkStorm.java | 1 - .../java/am2/illeffect/IllEffectsManager.java | 3 +- .../java/am2/items/ItemCrystalPhylactery.java | 3 +- src/main/java/am2/lore/StoryManager.java | 3 +- .../java/am2/navigation/PathNavigator.java | 14 +++---- .../am2/particles/ParticleArcToEntity.java | 4 +- .../am2/particles/ParticleArcToPoint.java | 6 +-- .../am2/particles/ParticleColorShift.java | 6 +-- .../am2/particles/ParticleController.java | 2 - .../am2/particles/ParticleFloatUpward.java | 2 +- .../am2/particles/ParticleManagerClient.java | 39 ++++++++++++++----- .../am2/particles/ParticleManagerServer.java | 1 - .../am2/particles/ParticleOrbitEntity.java | 10 ++--- .../am2/particles/ParticleOrbitPoint.java | 10 ++--- .../java/am2/particles/ParticlePendulum.java | 2 +- src/main/java/am2/spell/SpellHelper.java | 7 +--- .../java/am2/spell/components/Accelerate.java | 6 +-- src/main/java/am2/spell/components/Blink.java | 4 -- src/main/java/am2/spell/components/Grow.java | 13 +++---- .../am2/spell/components/RandomTeleport.java | 6 +-- src/main/java/am2/spell/components/Storm.java | 10 ++--- 60 files changed, 278 insertions(+), 322 deletions(-) diff --git a/src/main/java/am2/AMEventHandler.java b/src/main/java/am2/AMEventHandler.java index 5eab56b57..f3043d1cc 100644 --- a/src/main/java/am2/AMEventHandler.java +++ b/src/main/java/am2/AMEventHandler.java @@ -67,12 +67,9 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; -import java.util.Random; public class AMEventHandler{ - private final Random rand = new Random(); - @SubscribeEvent public void onPotionBrewed(PotionBrewedEvent brewEvent){ for (ItemStack stack : brewEvent.brewingStacks){ @@ -227,8 +224,6 @@ public void onEntityJump(LivingJumpEvent event){ double xVelocity = 0; double zVelocity = 0; - Random rand = new Random(); - Vec3 vec = event.entityLiving.getLookVec().normalize(); switch (event.entityLiving.getActivePotionEffect(BuffList.leap).getAmplifier() + 1){ case BuffPowerLevel.Low: @@ -569,8 +564,14 @@ public void onEntityAttacked(LivingAttackEvent event){ ExtendedProperties.For(event.entityLiving).deductMana(event.ammount * 100f); ExtendedProperties.For(event.entityLiving).forceSync(); for (int i = 0; i < Math.min(event.ammount, 5 * AMCore.config.getGFXLevel()); ++i) - AMCore.proxy.particleManager.BoltFromPointToPoint(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY + rand.nextFloat() * event.entityLiving.getEyeHeight(), event.entityLiving.posZ, event.entityLiving.posX - 1 + rand.nextFloat() * 2, event.entityLiving.posY - 1 + rand.nextFloat() * 2, event.entityLiving.posZ - 1 + rand.nextFloat() * 2, 6, -1); - event.entityLiving.worldObj.playSoundAtEntity(event.entityLiving, "arsmagica2:misc.event.mana_shield_block", 1.0f, rand.nextFloat() + 0.5f); + AMCore.proxy.particleManager.BoltFromPointToPoint(event.entityLiving.worldObj, + event.entityLiving.posX, + event.entityLiving.posY + event.entityLiving.worldObj.rand.nextFloat() * event.entityLiving.getEyeHeight(), + event.entityLiving.posZ, + event.entityLiving.posX - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, + event.entityLiving.posY - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, + event.entityLiving.posZ - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, 6, -1); + event.entityLiving.worldObj.playSoundAtEntity(event.entityLiving, "arsmagica2:misc.event.mana_shield_block", 1.0f, event.entityLiving.worldObj.rand.nextFloat() + 0.5f); event.setCanceled(true); return; } @@ -594,8 +595,14 @@ public void onEntityHurt(LivingHurtEvent event){ ExtendedProperties.For(event.entityLiving).deductMana(manaToTake); ExtendedProperties.For(event.entityLiving).forceSync(); for (int i = 0; i < Math.min(event.ammount, 5 * AMCore.config.getGFXLevel()); ++i) - AMCore.proxy.particleManager.BoltFromPointToPoint(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY + rand.nextFloat() * event.entityLiving.getEyeHeight(), event.entityLiving.posZ, event.entityLiving.posX - 1 + rand.nextFloat() * 2, event.entityLiving.posY + event.entityLiving.getEyeHeight() - 1 + rand.nextFloat() * 2, event.entityLiving.posZ - 1 + rand.nextFloat() * 2, 6, -1); - event.entityLiving.worldObj.playSoundAtEntity(event.entityLiving, "arsmagica2:misc.event.mana_shield_block", 1.0f, rand.nextFloat() + 0.5f); + AMCore.proxy.particleManager.BoltFromPointToPoint(event.entityLiving.worldObj, + event.entityLiving.posX, + event.entityLiving.posY + event.entityLiving.worldObj.rand.nextFloat() * event.entityLiving.getEyeHeight(), + event.entityLiving.posZ, + event.entityLiving.posX - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, + event.entityLiving.posY + event.entityLiving.getEyeHeight() - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, + event.entityLiving.posZ - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, 6, -1); + event.entityLiving.worldObj.playSoundAtEntity(event.entityLiving, "arsmagica2:misc.event.mana_shield_block", 1.0f, event.entityLiving.worldObj.rand.nextFloat() + 0.5f); if (event.ammount <= 0){ event.setCanceled(true); return; diff --git a/src/main/java/am2/affinity/AffinityHelper.java b/src/main/java/am2/affinity/AffinityHelper.java index 0dc91ad01..a14a63149 100644 --- a/src/main/java/am2/affinity/AffinityHelper.java +++ b/src/main/java/am2/affinity/AffinityHelper.java @@ -44,8 +44,6 @@ public class AffinityHelper{ - private final Random rand = new Random(); - @SubscribeEvent public void onEntityLivingBase(LivingUpdateEvent event){ EntityLivingBase ent = event.entityLiving; @@ -138,10 +136,10 @@ public void onEntityLivingBase(LivingUpdateEvent event){ } } - if (waterDepth > 0.4 && rand.nextInt(20) < 4) + if (waterDepth > 0.4 && ent.worldObj.rand.nextInt(20) < 4) ent.setAir(ent.getAir() + 1); - if (!ent.worldObj.isRemote && rand.nextInt(100) < 5){ + if (!ent.worldObj.isRemote && ent.worldObj.rand.nextInt(100) < 5){ ent.setAir(ent.getAir() + 1); byte[] data = new AMDataWriter().add(ent.getEntityId()).add(ent.getAir()).generate(); AMNetHandler.INSTANCE.sendPacketToClientPlayer((EntityPlayerMP)ent, AMPacketIDs.SYNC_AIR_CHANGE, data); @@ -164,11 +162,11 @@ public void onEntityLivingBase(LivingUpdateEvent event){ if (ent.worldObj.isRaining() && !ent.worldObj.isRemote && ent.worldObj.getBiomeGenForCoords((int)Math.floor(ent.posX), (int)Math.floor(ent.posZ)).canSpawnLightningBolt()){ float airDepth = affinityData.getAffinityDepth(Affinity.AIR); - if (airDepth > 0.5f && airDepth < 0.85f && !ent.worldObj.isRemote && rand.nextInt(100) < 10){ + if (airDepth > 0.5f && airDepth < 0.85f && !ent.worldObj.isRemote && ent.worldObj.rand.nextInt(100) < 10){ if (!ent.isSneaking() && !ent.isPotionActive(BuffList.gravityWell) && !ent.isInsideOfMaterial(Material.water) && ent.isWet()){ - double velX = rand.nextDouble() - 0.5; - double velY = rand.nextDouble() - 0.5; - double velZ = rand.nextDouble() - 0.5; + double velX = ent.worldObj.rand.nextDouble() - 0.5; + double velY = ent.worldObj.rand.nextDouble() - 0.5; + double velZ = ent.worldObj.rand.nextDouble() - 0.5; ent.addVelocity(velX, velY, velZ); AMNetHandler.INSTANCE.sendVelocityAddPacket(ent.worldObj, ent, velX, velY, velZ); } @@ -223,7 +221,7 @@ private void applyFulmintion(EntityPlayer ent, float lightningDepth){ AMCore.proxy.particleManager.BoltFromEntityToPoint(ent.worldObj, ent, ent.posX - 2 + ent.getRNG().nextDouble() * 4, ent.posY + ent.getEyeHeight() - 2 + ent.getRNG().nextDouble() * 4, ent.posZ - 2 + ent.getRNG().nextDouble() * 4); }else{ if (ent.getRNG().nextDouble() < 0.4f) - ent.worldObj.playSoundAtEntity(ent, "arsmagica2:misc.event.mana_shield_block", 1.0f, rand.nextFloat() + 0.5f); + ent.worldObj.playSoundAtEntity(ent, "arsmagica2:misc.event.mana_shield_block", 1.0f, ent.worldObj.rand.nextFloat() + 0.5f); } } } @@ -437,7 +435,7 @@ public void onSpellCast(SpellCastingEvent.Post event){ if (event.caster instanceof EntityPlayer && event.castResult == SpellCastResult.SUCCESS){ float affinityDepth = AffinityData.For(event.caster).getAffinityDepth(Affinity.ARCANE); if (affinityDepth > 0.4f){ - if (rand.nextInt(100) < 5 && !event.caster.worldObj.isRemote){ + if (event.caster.worldObj.rand.nextInt(100) < 5 && !event.caster.worldObj.isRemote){ event.caster.addPotionEffect(new BuffEffectClarity(140, 0)); } } diff --git a/src/main/java/am2/blocks/BlockArcaneReconstructor.java b/src/main/java/am2/blocks/BlockArcaneReconstructor.java index 6237f4397..fea0df589 100644 --- a/src/main/java/am2/blocks/BlockArcaneReconstructor.java +++ b/src/main/java/am2/blocks/BlockArcaneReconstructor.java @@ -16,15 +16,11 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import java.util.Random; public class BlockArcaneReconstructor extends AMSpecialRenderPoweredBlock{ - private final Random rand; - protected BlockArcaneReconstructor(){ super(Material.rock); - rand = new Random(); setHardness(3.0f); setResistance(3.0f); setBlockBounds(0, 0, 0, 1, 0.52f, 1); @@ -61,14 +57,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (itemstack == null){ continue; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -77,9 +73,9 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockArmorInfuser.java b/src/main/java/am2/blocks/BlockArmorInfuser.java index 6471f3692..2ffd479b9 100644 --- a/src/main/java/am2/blocks/BlockArmorInfuser.java +++ b/src/main/java/am2/blocks/BlockArmorInfuser.java @@ -106,7 +106,6 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat super.breakBlock(world, i, j, k, par5, metadata); return; } - Random rand = new Random(); TileEntityArmorImbuer imbuer = (TileEntityArmorImbuer)world.getTileEntity(i, j, k); if (imbuer == null) return; for (int l = 0; l < imbuer.getSizeInventory() - 3; l++){ @@ -114,14 +113,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (itemstack == null){ continue; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -130,9 +129,9 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockAstralBarrier.java b/src/main/java/am2/blocks/BlockAstralBarrier.java index 41c9645c3..32461aa87 100644 --- a/src/main/java/am2/blocks/BlockAstralBarrier.java +++ b/src/main/java/am2/blocks/BlockAstralBarrier.java @@ -66,7 +66,6 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat super.breakBlock(world, i, j, k, par5, metadata); return; } - Random rand = new Random(); TileEntityAstralBarrier barrier = (TileEntityAstralBarrier)world.getTileEntity(i, j, k); if (barrier == null) return; for (int l = 0; l < barrier.getSizeInventory() - 3; l++){ @@ -74,14 +73,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (itemstack == null){ continue; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -90,9 +89,9 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockCalefactor.java b/src/main/java/am2/blocks/BlockCalefactor.java index adcc68b1d..22b174d0a 100644 --- a/src/main/java/am2/blocks/BlockCalefactor.java +++ b/src/main/java/am2/blocks/BlockCalefactor.java @@ -54,7 +54,6 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat super.breakBlock(world, i, j, k, par5, metadata); return; } - Random rand = new Random(); TileEntityCalefactor calefactor = (TileEntityCalefactor)world.getTileEntity(i, j, k); if (calefactor == null) return; for (int l = 0; l < calefactor.getSizeInventory() - 3; l++){ @@ -62,14 +61,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (itemstack == null){ continue; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -78,9 +77,9 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockEssenceGenerator.java b/src/main/java/am2/blocks/BlockEssenceGenerator.java index 4372eb336..4a86fdfe4 100644 --- a/src/main/java/am2/blocks/BlockEssenceGenerator.java +++ b/src/main/java/am2/blocks/BlockEssenceGenerator.java @@ -130,7 +130,6 @@ public void breakBlock(World par1World, int par2, int par3, int par4, Block par5 super.breakBlock(par1World, par2, par3, par4, par5, par6); return; } - Random rand = new Random(); TileEntityObelisk obelisk = getTileEntity(par1World, par2, par3, par4); if (obelisk == null) return; for (int l = 0; l < obelisk.getSizeInventory(); l++){ @@ -138,14 +137,14 @@ public void breakBlock(World par1World, int par2, int par3, int par4, Block par5 if (itemstack == null){ continue; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = par1World.rand.nextFloat() * 0.8F + 0.1F; + float f1 = par1World.rand.nextFloat() * 0.8F + 0.1F; + float f2 = par1World.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = par1World.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -154,9 +153,9 @@ public void breakBlock(World par1World, int par2, int par3, int par4, Block par5 newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)par1World.rand.nextGaussian() * f3; + entityitem.motionY = (float)par1World.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)par1World.rand.nextGaussian() * f3; par1World.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockEssenceRefiner.java b/src/main/java/am2/blocks/BlockEssenceRefiner.java index 28a7ea6ee..1b3a3f59f 100644 --- a/src/main/java/am2/blocks/BlockEssenceRefiner.java +++ b/src/main/java/am2/blocks/BlockEssenceRefiner.java @@ -27,7 +27,6 @@ public class BlockEssenceRefiner extends PoweredBlock{ - private Random essenceRefinerRand; private static boolean keepRefinerInventory = false; @SideOnly(Side.CLIENT) @@ -36,7 +35,6 @@ public class BlockEssenceRefiner extends PoweredBlock{ public BlockEssenceRefiner(){ super(Material.wood); - essenceRefinerRand = new Random(); setHardness(2.0f); } @@ -166,14 +164,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (itemstack == null){ continue; } - float f = essenceRefinerRand.nextFloat() * 0.8F + 0.1F; - float f1 = essenceRefinerRand.nextFloat() * 0.8F + 0.1F; - float f2 = essenceRefinerRand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = essenceRefinerRand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -182,9 +180,9 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)essenceRefinerRand.nextGaussian() * f3; - entityitem.motionY = (float)essenceRefinerRand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)essenceRefinerRand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockFlickerHabitat.java b/src/main/java/am2/blocks/BlockFlickerHabitat.java index e67b1c8ef..f23d759aa 100644 --- a/src/main/java/am2/blocks/BlockFlickerHabitat.java +++ b/src/main/java/am2/blocks/BlockFlickerHabitat.java @@ -155,18 +155,17 @@ public void breakBlock(World world, int x, int y, int z, Block oldBlockID, int o //if the habitat has a flicker throw it on the ground if (habitat.hasFlicker()){ - Random rand = new Random(); ItemStack stack = habitat.getStackInSlot(0); - float offsetX = rand.nextFloat() * 0.8F + 0.1F; - float offsetY = rand.nextFloat() * 0.8F + 0.1F; - float offsetZ = rand.nextFloat() * 0.8F + 0.1F; + float offsetX = world.rand.nextFloat() * 0.8F + 0.1F; + float offsetY = world.rand.nextFloat() * 0.8F + 0.1F; + float offsetZ = world.rand.nextFloat() * 0.8F + 0.1F; float force = 0.05F; EntityItem entityItem = new EntityItem(world, x + offsetX, y + offsetY, z + offsetZ, stack); - entityItem.motionX = (float)rand.nextGaussian() * force; - entityItem.motionY = (float)rand.nextGaussian() * force + 0.2F; - entityItem.motionZ = (float)rand.nextGaussian() * force; + entityItem.motionX = (float)world.rand.nextGaussian() * force; + entityItem.motionY = (float)world.rand.nextGaussian() * force + 0.2F; + entityItem.motionZ = (float)world.rand.nextGaussian() * force; world.spawnEntityInWorld(entityItem); } diff --git a/src/main/java/am2/blocks/BlockInertSpawner.java b/src/main/java/am2/blocks/BlockInertSpawner.java index a2f2b5008..596446ab9 100644 --- a/src/main/java/am2/blocks/BlockInertSpawner.java +++ b/src/main/java/am2/blocks/BlockInertSpawner.java @@ -68,18 +68,17 @@ public void breakBlock(World world, int x, int y, int z, Block oldBlockID, int o //if the habitat has a flicker throw it on the ground if (spawner.getStackInSlot(0) != null){ - Random rand = new Random(); ItemStack stack = spawner.getStackInSlot(0); - float offsetX = rand.nextFloat() * 0.8F + 0.1F; - float offsetY = rand.nextFloat() * 0.8F + 0.1F; - float offsetZ = rand.nextFloat() * 0.8F + 0.1F; + float offsetX = world.rand.nextFloat() * 0.8F + 0.1F; + float offsetY = world.rand.nextFloat() * 0.8F + 0.1F; + float offsetZ = world.rand.nextFloat() * 0.8F + 0.1F; float force = 0.05F; EntityItem entityItem = new EntityItem(world, x + offsetX, y + offsetY, z + offsetZ, stack); - entityItem.motionX = (float)rand.nextGaussian() * force; - entityItem.motionY = (float)rand.nextGaussian() * force + 0.2F; - entityItem.motionZ = (float)rand.nextGaussian() * force; + entityItem.motionX = (float)world.rand.nextGaussian() * force; + entityItem.motionY = (float)world.rand.nextGaussian() * force + 0.2F; + entityItem.motionZ = (float)world.rand.nextGaussian() * force; world.spawnEntityInWorld(entityItem); } diff --git a/src/main/java/am2/blocks/BlockInscriptionTable.java b/src/main/java/am2/blocks/BlockInscriptionTable.java index 86995c06e..c52b1d6d8 100644 --- a/src/main/java/am2/blocks/BlockInscriptionTable.java +++ b/src/main/java/am2/blocks/BlockInscriptionTable.java @@ -218,15 +218,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat } private void spawnItemOnBreak(World world, int i, int j, int k, Block par5, int metadata, ItemStack itemstack){ - Random rand = new Random(); - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -235,9 +234,9 @@ private void spawnItemOnBreak(World world, int i, int j, int k, Block par5, int newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockKeystoneChest.java b/src/main/java/am2/blocks/BlockKeystoneChest.java index 0960319d0..e93e93b3b 100644 --- a/src/main/java/am2/blocks/BlockKeystoneChest.java +++ b/src/main/java/am2/blocks/BlockKeystoneChest.java @@ -93,7 +93,6 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat super.breakBlock(world, i, j, k, par5, metadata); return; } - Random rand = new Random(); TileEntityKeystoneChest receptacle = (TileEntityKeystoneChest)world.getTileEntity(i, j, k); if (receptacle == null) return; @@ -105,14 +104,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (itemstack == null){ continue; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -121,9 +120,9 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockLectern.java b/src/main/java/am2/blocks/BlockLectern.java index 03b446b11..10d80ee43 100644 --- a/src/main/java/am2/blocks/BlockLectern.java +++ b/src/main/java/am2/blocks/BlockLectern.java @@ -40,21 +40,20 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p if (te == null){ return true; } - Random rand = new Random(); if (te.hasStack()){ if (player.isSneaking()){ if (!world.isRemote && ((player instanceof EntityPlayerMP) && ((EntityPlayerMP)player).theItemInWorldManager.getGameType() != GameType.ADVENTURE)){ - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; ItemStack newItem = new ItemStack(te.getStack().getItem(), 1, te.getStack().getItemDamage()); if (te.getStack().stackTagCompound != null) newItem.setTagCompound((NBTTagCompound)te.getStack().stackTagCompound.copy()); EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); te.setStack(null); } @@ -82,19 +81,18 @@ public void breakBlock(World world, int x, int y, int z, Block par5, int par6){ return; } if (!world.isRemote){ - Random rand = new Random(); if (te.hasStack()){ - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; ItemStack newItem = new ItemStack(te.getStack().getItem(), 1, te.getStack().getItemDamage()); if (te.getStack().stackTagCompound != null) newItem.setTagCompound((NBTTagCompound)te.getStack().stackTagCompound.copy()); EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); } } diff --git a/src/main/java/am2/blocks/BlockMageLight.java b/src/main/java/am2/blocks/BlockMageLight.java index f677e0079..d5c1b1140 100644 --- a/src/main/java/am2/blocks/BlockMageLight.java +++ b/src/main/java/am2/blocks/BlockMageLight.java @@ -24,8 +24,6 @@ public class BlockMageLight extends AMSpecialRenderBlock{ - private final Random rand = new Random(); - protected BlockMageLight(){ super(Material.circuits); setBlockBounds(0.35f, 0.35f, 0.35f, 0.65f, 0.65f, 0.65f); @@ -39,7 +37,7 @@ public int tickRate(World par1World){ @Override @SideOnly(Side.CLIENT) - public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random){ + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random rand){ int meta = par1World.getBlockMetadata(par2, par3, par4); int color = ItemDye.field_150922_c[meta]; diff --git a/src/main/java/am2/blocks/BlockMagiciansWorkbench.java b/src/main/java/am2/blocks/BlockMagiciansWorkbench.java index 8bab2e37d..0dd2a65ef 100644 --- a/src/main/java/am2/blocks/BlockMagiciansWorkbench.java +++ b/src/main/java/am2/blocks/BlockMagiciansWorkbench.java @@ -138,7 +138,6 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat super.breakBlock(world, i, j, k, par5, metadata); return; } - Random rand = new Random(); TileEntityMagiciansWorkbench workbench = (TileEntityMagiciansWorkbench)world.getTileEntity(i, j, k); if (workbench == null || KeystoneUtilities.instance.getKeyFromRunes(workbench.getRunesInKey()) != 0) return; @@ -147,14 +146,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (itemstack == null){ continue; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -163,23 +162,23 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } if(workbench.getUpgradeStatus(TileEntityMagiciansWorkbench.UPG_CRAFT)){ - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; ItemStack newItem = new ItemStack(ItemsCommonProxy.workbenchUpgrade, 1); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); } diff --git a/src/main/java/am2/blocks/BlockManaBattery.java b/src/main/java/am2/blocks/BlockManaBattery.java index 4396a0bc9..647b028fe 100644 --- a/src/main/java/am2/blocks/BlockManaBattery.java +++ b/src/main/java/am2/blocks/BlockManaBattery.java @@ -134,11 +134,10 @@ public void onBlockPreDestroy(World par1World, int par2, int par3, int par4, int private void destroy(World world, int i, int j, int k){ TileEntityManaBattery te = getTileEntity(world, i, j, k); - Random rand = new Random(); if (te != null && !world.isRemote){ - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; int dmg = (int)((PowerNodeRegistry.For(world).getPower(te, te.getPowerType()) / te.getCapacity()) * 100); if (dmg == 0) dmg = 1; ItemStack stack = new ItemStack(this); @@ -158,9 +157,9 @@ private void destroy(World world, int i, int j, int k){ EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, stack); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); } } diff --git a/src/main/java/am2/blocks/BlockSeerStone.java b/src/main/java/am2/blocks/BlockSeerStone.java index 25960869c..63e8ea44f 100644 --- a/src/main/java/am2/blocks/BlockSeerStone.java +++ b/src/main/java/am2/blocks/BlockSeerStone.java @@ -196,7 +196,6 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat super.breakBlock(world, i, j, k, par5, metadata); return; } - Random rand = new Random(); TileEntitySeerStone myTE = (TileEntitySeerStone)world.getTileEntity(i, j, k); if (myTE == null) return; for (int l = 0; l < myTE.getSizeInventory() - 3; l++){ @@ -204,14 +203,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (itemstack == null){ continue; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -220,9 +219,9 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockSpellSealedDoor.java b/src/main/java/am2/blocks/BlockSpellSealedDoor.java index 59836d96c..192c714a7 100644 --- a/src/main/java/am2/blocks/BlockSpellSealedDoor.java +++ b/src/main/java/am2/blocks/BlockSpellSealedDoor.java @@ -27,7 +27,6 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import java.util.Random; public class BlockSpellSealedDoor extends BlockDoor implements ITileEntityProvider{ @@ -153,21 +152,20 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (world.getBlock(i, j - 1, k) == BlocksCommonProxy.spellSealedDoor) j--; - Random rand = new Random(); TileEntitySpellSealedDoor door = (TileEntitySpellSealedDoor)world.getTileEntity(i, j, k); if (door == null) return; ItemStack itemstack = door.getStackInSlot(3); if (itemstack == null){ return; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -176,9 +174,9 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); diff --git a/src/main/java/am2/blocks/BlockSummoner.java b/src/main/java/am2/blocks/BlockSummoner.java index 749bdcd86..9660896a8 100644 --- a/src/main/java/am2/blocks/BlockSummoner.java +++ b/src/main/java/am2/blocks/BlockSummoner.java @@ -21,7 +21,6 @@ import net.minecraft.util.Vec3; import net.minecraft.world.World; -import java.util.Random; public class BlockSummoner extends AMSpecialRenderPoweredBlock{ @@ -92,7 +91,6 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat super.breakBlock(world, i, j, k, par5, metadata); return; } - Random rand = new Random(); TileEntitySummoner summoner = (TileEntitySummoner)world.getTileEntity(i, j, k); if (summoner == null) return; for (int l = 0; l < summoner.getSizeInventory() - 3; l++){ @@ -100,14 +98,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (itemstack == null){ continue; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -118,9 +116,9 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat } EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newStack); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/IllusionBlock.java b/src/main/java/am2/blocks/IllusionBlock.java index ca55ce2a2..e6d05d37d 100644 --- a/src/main/java/am2/blocks/IllusionBlock.java +++ b/src/main/java/am2/blocks/IllusionBlock.java @@ -91,7 +91,6 @@ public AMVector3 getMimicLocation(IBlockAccess blockAccess, int x, int y, int z) AMVector3 position = new AMVector3(x, y, z); AMVector3 offset = new AMVector3(dir.offsetX, dir.offsetY, dir.offsetZ); int count = 0; - boolean found = false; while (count++ < SEARCH_MAX_DIST){ position = position.add(offset); @@ -272,7 +271,7 @@ public int GetCraftingQuantity(){ */ @Override public void randomDisplayTick(World world, int i, int j, int k, Random random){ - int meta = world.getBlockMetadata(i, j, k); + // int meta = world.getBlockMetadata(i, j, k); EntityPlayer closest = world.getClosestPlayer(i, j, k, 5.0); if (closest == null){ @@ -280,19 +279,17 @@ public void randomDisplayTick(World world, int i, int j, int k, Random random){ return; }else if (closest.isPotionActive(BuffList.trueSight.id)){ world.markBlockForUpdate(i, j, k); - Random rnd = new Random(); if (tickCount++ == 20){ this.tickCount = 0; for (int x = 0; x < 10; ++x){ - double factor = 1; double movement = 2; world.spawnParticle("reddust", - i + ((rnd.nextDouble() * 2 - 1) * movement), - j + ((rnd.nextDouble() * 2 - 1) * movement), - k + ((rnd.nextDouble() * 2 - 1) * movement), - rnd.nextDouble() / 4 + 0.75, + i + ((random.nextDouble() * 2 - 1) * movement), + j + ((random.nextDouble() * 2 - 1) * movement), + k + ((random.nextDouble() * 2 - 1) * movement), + random.nextDouble() / 4 + 0.75, 0.5f, - rnd.nextDouble() / 2 + 0.75); + random.nextDouble() / 2 + 0.75); } } }else{ diff --git a/src/main/java/am2/blocks/tileentities/TileEntityArcaneReconstructor.java b/src/main/java/am2/blocks/tileentities/TileEntityArcaneReconstructor.java index 04b2a3079..5a5b6637c 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityArcaneReconstructor.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityArcaneReconstructor.java @@ -46,8 +46,6 @@ public class TileEntityArcaneReconstructor extends TileEntityAMPower implements private final AMVector3 middleRingRotationSpeeds; private final AMVector3 innerRingRotationSpeeds; - private final Random rand; - private static final int SLOT_ACTIVE = 3; public TileEntityArcaneReconstructor(){ @@ -60,10 +58,9 @@ public TileEntityArcaneReconstructor(){ middleRingRotation = new AMVector3(0, 0, 0); innerRingRotation = new AMVector3(0, 0, 0); - rand = new Random(); - outerRingRotationSpeeds = new AMVector3(rand.nextDouble() * 4 - 2, rand.nextDouble() * 4 - 2, rand.nextDouble() * 4 - 2); - middleRingRotationSpeeds = new AMVector3(rand.nextDouble() * 4 - 2, rand.nextDouble() * 4 - 2, rand.nextDouble() * 4 - 2); - innerRingRotationSpeeds = new AMVector3(rand.nextDouble() * 4 - 2, rand.nextDouble() * 4 - 2, rand.nextDouble() * 4 - 2); + outerRingRotationSpeeds = new AMVector3(worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2); + middleRingRotationSpeeds = new AMVector3(worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2); + innerRingRotationSpeeds = new AMVector3(worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2); } @@ -101,7 +98,7 @@ public void updateEntity(){ if (worldObj.isRemote){ updateRotations(); if (shouldRenderItemStack()){ - AMParticle p = (AMParticle)AMCore.instance.proxy.particleManager.spawn(worldObj, "sparkle2", xCoord + 0.2 + (rand.nextDouble() * 0.6), yCoord + 0.4, zCoord + 0.2 + (rand.nextDouble() * 0.6)); + AMParticle p = (AMParticle)AMCore.instance.proxy.particleManager.spawn(worldObj, "sparkle2", xCoord + 0.2 + (worldObj.rand.nextDouble() * 0.6), yCoord + 0.4, zCoord + 0.2 + (worldObj.rand.nextDouble() * 0.6)); if (p != null){ p.AddParticleController(new ParticleFloatUpward(p, 0.0f, 0.02f, 1, false)); p.setIgnoreMaxAge(true); diff --git a/src/main/java/am2/blocks/tileentities/TileEntityAstralBarrier.java b/src/main/java/am2/blocks/tileentities/TileEntityAstralBarrier.java index 6286e399f..e9f49c66d 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityAstralBarrier.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityAstralBarrier.java @@ -30,7 +30,6 @@ public class TileEntityAstralBarrier extends TileEntityAMPower implements IInven private static final int maxRadius = 20; private static final int minRadius = 5; private boolean displayAura; - private Random rand; private int particleTickCounter; public static int keystoneSlot = 0; @@ -39,7 +38,6 @@ public TileEntityAstralBarrier(){ super(250); inventory = new ItemStack[getSizeInventory()]; displayAura = false; - rand = new Random(); particleTickCounter = 0; } @@ -101,13 +99,13 @@ public void updateEntity(){ particleTickCounter = 0; String particleName = ""; - AMParticle effect = (AMParticle)AMCore.instance.proxy.particleManager.spawn(worldObj, "sparkle", xCoord + 0.5, yCoord + 0.1 + rand.nextDouble() * 0.5, zCoord + 0.5); + AMParticle effect = (AMParticle)AMCore.instance.proxy.particleManager.spawn(worldObj, "sparkle", xCoord + 0.5, yCoord + 0.1 + worldObj.rand.nextDouble() * 0.5, zCoord + 0.5); if (effect != null){ effect.setIgnoreMaxAge(false); effect.setMaxAge(100); effect.setParticleScale(0.5f); - float color = rand.nextFloat() * 0.2f + 0.8f; - effect.AddParticleController(new ParticleOrbitPoint(effect, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 1, false).SetOrbitSpeed(0.005).SetTargetDistance(rand.nextDouble() * 0.6 - 0.3)); + float color = worldObj.rand.nextFloat() * 0.2f + 0.8f; + effect.AddParticleController(new ParticleOrbitPoint(effect, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 1, false).SetOrbitSpeed(0.005).SetTargetDistance(worldObj.rand.nextDouble() * 0.6 - 0.3)); effect.AddParticleController(new ParticleHoldPosition(effect, 80, 2, true)); effect.AddParticleController(new ParticleFadeOut(effect, 3, false).setFadeSpeed(0.05f)); } diff --git a/src/main/java/am2/blocks/tileentities/TileEntityCalefactor.java b/src/main/java/am2/blocks/tileentities/TileEntityCalefactor.java index f2f78c00b..d6527d049 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityCalefactor.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityCalefactor.java @@ -44,12 +44,10 @@ public class TileEntityCalefactor extends TileEntityAMPower implements IInventor public TileEntityCalefactor(){ super(100); - Random rand = new Random(); - calefactorItemStacks = new ItemStack[getSizeInventory()]; - rotationStepX = rand.nextFloat() * 0.03f - 0.015f; - rotationStepY = rand.nextFloat() * 0.03f - 0.015f; - rotationStepZ = rand.nextFloat() * 0.03f - 0.015f; + rotationStepX = worldObj.rand.nextFloat() * 0.03f - 0.015f; + rotationStepY = worldObj.rand.nextFloat() * 0.03f - 0.015f; + rotationStepZ = worldObj.rand.nextFloat() * 0.03f - 0.015f; isCooking = false; } diff --git a/src/main/java/am2/blocks/tileentities/TileEntityEssenceConduit.java b/src/main/java/am2/blocks/tileentities/TileEntityEssenceConduit.java index 51f43fd4f..0cdfb1450 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityEssenceConduit.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityEssenceConduit.java @@ -18,16 +18,15 @@ public class TileEntityEssenceConduit extends TileEntityAMPower{ public TileEntityEssenceConduit(){ super(1); - Random rand = new Random(); - rotationX = rand.nextInt(360); - rotationY = rand.nextInt(360); - rotationZ = rand.nextInt(360); + rotationX = worldObj.rand.nextInt(360); + rotationY = worldObj.rand.nextInt(360); + rotationZ = worldObj.rand.nextInt(360); redstonePowered = false; - rotationIncrementX = rand.nextFloat() * 0.002f + 0.005f; - rotationIncrementY = rand.nextFloat() * 0.002f + 0.005f; - rotationIncrementZ = rand.nextFloat() * 0.002f + 0.005f; + rotationIncrementX = worldObj.rand.nextFloat() * 0.002f + 0.005f; + rotationIncrementY = worldObj.rand.nextFloat() * 0.002f + 0.005f; + rotationIncrementZ = worldObj.rand.nextFloat() * 0.002f + 0.005f; } diff --git a/src/main/java/am2/blocks/tileentities/TileEntityFlickerHabitat.java b/src/main/java/am2/blocks/tileentities/TileEntityFlickerHabitat.java index deed74deb..9e87cbb05 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityFlickerHabitat.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityFlickerHabitat.java @@ -71,9 +71,8 @@ public TileEntityFlickerHabitat(){ initLocationLists(); if (worldObj != null && worldObj.isRemote){ - Random rnd = new Random(System.currentTimeMillis()); - rotateOffset = rnd.nextFloat() * FULL_CIRCLE - 1; - floatOffset = MAX_FLOAT_DOWN + (rnd.nextFloat() * (MAX_FLOAT_UP - MAX_FLOAT_DOWN) + 1); + rotateOffset = worldObj.rand.nextFloat() * FULL_CIRCLE - 1; + floatOffset = MAX_FLOAT_DOWN + (worldObj.rand.nextFloat() * (MAX_FLOAT_UP - MAX_FLOAT_DOWN) + 1); } } diff --git a/src/main/java/am2/blocks/tileentities/TileEntityInscriptionTable.java b/src/main/java/am2/blocks/tileentities/TileEntityInscriptionTable.java index 9dc087fed..b50eac8c2 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityInscriptionTable.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityInscriptionTable.java @@ -57,7 +57,6 @@ public class TileEntityInscriptionTable extends TileEntity implements IInventory public static int inkIndex = 3; private EntityPlayer currentPlayerUsing; private int ticksToNextParticle = 20; - private final Random rand; private final HashMap modifierCount; private String currentSpellName; private boolean currentSpellIsReadOnly; @@ -69,7 +68,6 @@ public class TileEntityInscriptionTable extends TileEntity implements IInventory public TileEntityInscriptionTable(){ inscriptionTableItemStacks = new ItemStack[getSizeInventory()]; currentPlayerUsing = null; - rand = new Random(); currentSpellName = ""; currentRecipe = new ArrayList(); shapeGroups = new ArrayList>(); @@ -216,13 +214,13 @@ private void candleUpdate(){ effect.setMaxAge(400); } - if (rand.nextInt(100) > 80){ + if (worldObj.rand.nextInt(100) > 80){ AMParticle smoke = (AMParticle)AMCore.proxy.particleManager.spawn(worldObj, "smoke", particleX, yCoord + 1.4, particleZ); if (smoke != null){ smoke.setParticleScale(0.025f); smoke.AddParticleController(new ParticleFloatUpward(smoke, 0.01f, 0.01f, 1, false)); smoke.setIgnoreMaxAge(false); - smoke.setMaxAge(20 + rand.nextInt(10)); + smoke.setMaxAge(20 + worldObj.rand.nextInt(10)); } } } @@ -260,13 +258,13 @@ private void candleUpdate(){ effect.setMaxAge(400); } - if (rand.nextInt(100) > 80){ + if (worldObj.rand.nextInt(100) > 80){ AMParticle smoke = (AMParticle)AMCore.proxy.particleManager.spawn(worldObj, "smoke", particleX, yCoord + 1.4, particleZ); if (smoke != null){ smoke.setParticleScale(0.025f); smoke.AddParticleController(new ParticleFloatUpward(smoke, 0.01f, 0.01f, 1, false)); smoke.setIgnoreMaxAge(false); - smoke.setMaxAge(20 + rand.nextInt(10)); + smoke.setMaxAge(20 + worldObj.rand.nextInt(10)); } } } diff --git a/src/main/java/am2/blocks/tileentities/TileEntityKeystoneRecepticle.java b/src/main/java/am2/blocks/tileentities/TileEntityKeystoneRecepticle.java index 0255c01b0..83d579eba 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityKeystoneRecepticle.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityKeystoneRecepticle.java @@ -36,7 +36,6 @@ public class TileEntityKeystoneRecepticle extends TileEntityAMPower implements I private boolean isActive; private long key; - private final Random rand; private final int boltType = 2; private int surroundingCheckTicks = 20; @@ -50,7 +49,6 @@ public class TileEntityKeystoneRecepticle extends TileEntityAMPower implements I public TileEntityKeystoneRecepticle(){ super(250000); this.isActive = false; - this.rand = new Random(); inventory = new ItemStack[getSizeInventory()]; initMultiblock(); } diff --git a/src/main/java/am2/blocks/tileentities/TileEntityLectern.java b/src/main/java/am2/blocks/tileentities/TileEntityLectern.java index 5503e9a27..136ae9812 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityLectern.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityLectern.java @@ -23,7 +23,6 @@ public class TileEntityLectern extends TileEntityEnchantmentTable{ private ItemStack stack; - private Random rand; private ItemStack tooltipStack; private boolean needsBook; private boolean overPowered; @@ -32,7 +31,6 @@ public class TileEntityLectern extends TileEntityEnchantmentTable{ private boolean increasing = true; public TileEntityLectern(){ - rand = new Random(); } public void resetParticleAge(){ @@ -53,9 +51,9 @@ public void updateEntity(){ if (worldObj.isRemote){ updateBookRender(); if (tooltipStack != null && field_145926_a % 2 == 0){ - AMParticle particle = (AMParticle)AMCore.proxy.particleManager.spawn(worldObj, "sparkle", xCoord + 0.5 + ((rand.nextDouble() * 0.2) - 0.1), yCoord + 1, zCoord + 0.5 + ((rand.nextDouble() * 0.2) - 0.1)); + AMParticle particle = (AMParticle)AMCore.proxy.particleManager.spawn(worldObj, "sparkle", xCoord + 0.5 + ((worldObj.rand.nextDouble() * 0.2) - 0.1), yCoord + 1, zCoord + 0.5 + ((worldObj.rand.nextDouble() * 0.2) - 0.1)); if (particle != null){ - particle.AddParticleController(new ParticleMoveOnHeading(particle, rand.nextDouble() * 360, -45 - rand.nextInt(90), 0.05f, 1, false)); + particle.AddParticleController(new ParticleMoveOnHeading(particle, worldObj.rand.nextDouble() * 360, -45 - worldObj.rand.nextInt(90), 0.05f, 1, false)); particle.AddParticleController(new ParticleFadeOut(particle, 2, false).setFadeSpeed(0.05f).setKillParticleOnFinish(true)); particle.setIgnoreMaxAge(true); if (getOverpowered()){ @@ -82,11 +80,11 @@ private void updateBookRender(){ this.field_145930_m += 0.1F; - if (this.field_145930_m < 0.5F || rand.nextInt(40) == 0){ + if (this.field_145930_m < 0.5F || worldObj.rand.nextInt(40) == 0){ float f1 = this.field_145932_k; do{ - this.field_145932_k += (float)(rand.nextInt(4) - rand.nextInt(4)); + this.field_145932_k += (float)(worldObj.rand.nextInt(4) - worldObj.rand.nextInt(4)); } while (f1 == this.field_145932_k); } diff --git a/src/main/java/am2/blocks/tileentities/TileEntityParticleEmitter.java b/src/main/java/am2/blocks/tileentities/TileEntityParticleEmitter.java index a9854a899..7b2146f6a 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityParticleEmitter.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityParticleEmitter.java @@ -39,8 +39,6 @@ public class TileEntityParticleEmitter extends TileEntity{ private int showTicks = 0; boolean forceShow; - private Random random = new Random(); - public TileEntityParticleEmitter(){ particleType = 0; particleQuantity = 1; @@ -53,7 +51,7 @@ public TileEntityParticleEmitter(){ randomColor = false; show = true; forceShow = false; - fullUpdateDelayTicks = random.nextInt(40); + fullUpdateDelayTicks = worldObj.rand.nextInt(40); } @Override @@ -88,9 +86,9 @@ public void updateEntity(){ private void doSpawn(){ if (!hasReceivedFullUpdate) return; - double x = randomzieCoord(xCoord + 0.5); - double y = randomzieCoord(yCoord + 0.5); - double z = randomzieCoord(zCoord + 0.5); + double x = randomizeCoord(xCoord + 0.5); + double y = randomizeCoord(yCoord + 0.5); + double z = randomizeCoord(zCoord + 0.5); AMParticle particle = (AMParticle)AMCore.proxy.particleManager.spawn(worldObj, AMParticle.particleTypes[particleType], x, y, z); if (particle != null){ particle.AddParticleController(AMCore.proxy.particleManager.createDefaultParticleController(particleBehaviour, particle, new AMVector3(x, y, z), speed, worldObj.getBlockMetadata(xCoord, yCoord, zCoord))); @@ -102,13 +100,13 @@ private void doSpawn(){ if (!randomColor) particle.setRGBColorF(((particleColor >> 16) & 0xFF) / 255f, ((particleColor >> 8) & 0xFF) / 255f, (particleColor & 0xFF) / 255f); else - particle.setRGBColorF(random.nextFloat(), random.nextFloat(), random.nextFloat()); + particle.setRGBColorF(worldObj.rand.nextFloat(), worldObj.rand.nextFloat(), worldObj.rand.nextFloat()); } } } - private double randomzieCoord(double base){ - return base + random.nextDouble() - 0.5; + private double randomizeCoord(double base){ + return base + worldObj.rand.nextDouble() - 0.5; } @Override diff --git a/src/main/java/am2/blocks/tileentities/TileEntitySeerStone.java b/src/main/java/am2/blocks/tileentities/TileEntitySeerStone.java index 0cc60a05b..60059e9e2 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntitySeerStone.java +++ b/src/main/java/am2/blocks/tileentities/TileEntitySeerStone.java @@ -129,7 +129,7 @@ public boolean isInvertingDetection(){ private SpriteRenderInfo GetWeightedRandomAnimation(){ currentAnimation.reset(false); - int randomNumber = new Random().nextInt(100); + int randomNumber = worldObj.rand.nextInt(100); int index = 0; SpriteRenderInfo current = animations.get(0); diff --git a/src/main/java/am2/bosses/ai/EntityAIChaosWaterBolt.java b/src/main/java/am2/bosses/ai/EntityAIChaosWaterBolt.java index 784e7f5d0..704b554c2 100644 --- a/src/main/java/am2/bosses/ai/EntityAIChaosWaterBolt.java +++ b/src/main/java/am2/bosses/ai/EntityAIChaosWaterBolt.java @@ -13,7 +13,6 @@ public class EntityAIChaosWaterBolt extends EntityAIBase{ private final EntityWaterGuardian host; private int cooldownTicks = 0; - private final Random rand; private static final ItemStack castStack = createDummyStack(); @@ -26,7 +25,6 @@ private static ItemStack createDummyStack(){ public EntityAIChaosWaterBolt(EntityWaterGuardian host){ this.host = host; this.setMutexBits(1); - rand = new Random(); } @Override @@ -51,7 +49,7 @@ public void updateTask(){ host.setCurrentAction(BossActions.CASTING); if (!host.worldObj.isRemote && host.getCurrentAction() == BossActions.CASTING){ - float yaw = rand.nextFloat() * 360; + float yaw = host.worldObj.rand.nextFloat() * 360; host.rotationYaw = yaw; host.prevRotationYaw = yaw; SpellHelper.instance.applyStackStage(castStack, host, host, host.posX, host.posY, host.posZ, 0, host.worldObj, false, false, 0); diff --git a/src/main/java/am2/buffs/BuffEffect.java b/src/main/java/am2/buffs/BuffEffect.java index 890d2ca4f..e78e13201 100644 --- a/src/main/java/am2/buffs/BuffEffect.java +++ b/src/main/java/am2/buffs/BuffEffect.java @@ -11,14 +11,12 @@ public abstract class BuffEffect extends PotionEffect{ protected boolean InitialApplication; protected boolean HasNotified; - protected Random rand; private static float maxExtendDuration = 900; //30 seconds public BuffEffect(int buffID, int duration, int amplifier){ super(buffID, duration, amplifier > 0 ? amplifier - 1 : amplifier); InitialApplication = true; HasNotified = ((duration / 20) > 5) ? false : true; //disable notification for effects that last less than 5 seconds - rand = new Random(); } public static boolean SetAmplifier(PotionEffect pe, int amplifier){ diff --git a/src/main/java/am2/buffs/BuffEffectRegeneration.java b/src/main/java/am2/buffs/BuffEffectRegeneration.java index 13a3eac18..1bed1aa77 100644 --- a/src/main/java/am2/buffs/BuffEffectRegeneration.java +++ b/src/main/java/am2/buffs/BuffEffectRegeneration.java @@ -33,9 +33,12 @@ public boolean onUpdate(EntityLivingBase entityliving){ if (!world.isRemote){ entityliving.heal(1); }else{ - AMParticle effect = (AMParticle)AMCore.instance.proxy.particleManager.spawn(world, "hr_sparkles_1", entityliving.posX + rand.nextDouble() * entityliving.height - (entityliving.height / 2), entityliving.posY + rand.nextDouble() * entityliving.height - (entityliving.height / 2), entityliving.posZ + rand.nextDouble() * entityliving.height - (entityliving.height / 2)); + AMParticle effect = (AMParticle)AMCore.instance.proxy.particleManager.spawn(world, "hr_sparkles_1", + entityliving.posX + world.rand.nextDouble() * entityliving.height - (entityliving.height / 2), + entityliving.posY + world.rand.nextDouble() * entityliving.height - (entityliving.height / 2), + entityliving.posZ + world.rand.nextDouble() * entityliving.height - (entityliving.height / 2)); if (effect != null){ - effect.setMaxAge(15 + rand.nextInt(10)); + effect.setMaxAge(15 + world.rand.nextInt(10)); effect.setIgnoreMaxAge(false); effect.AddParticleController(new ParticleFadeOut(effect, 1, true)); effect.setRGBColorF(0.15f, 0.92f, 0.37f); diff --git a/src/main/java/am2/commands/Explosions.java b/src/main/java/am2/commands/Explosions.java index be33bc6ee..53c56c423 100644 --- a/src/main/java/am2/commands/Explosions.java +++ b/src/main/java/am2/commands/Explosions.java @@ -25,17 +25,16 @@ public String getCommandUsage(ICommandSender icommandsender){ @Override public void processCommand(ICommandSender icommandsender, String[] astring){ EntityPlayer player = getCommandSenderAsPlayer(icommandsender); - Random rand = new Random(); if (player.getCommandSenderName().equals("Moridrex") || player.getCommandSenderName().equals("Mithion")){ - if (rand.nextInt(10) < 5 || !player.worldObj.canBlockSeeTheSky((int)player.posX, (int)player.posY, (int)player.posZ)){ + if (player.worldObj.rand.nextInt(10) < 5 || !player.worldObj.canBlockSeeTheSky((int)player.posX, (int)player.posY, (int)player.posZ)){ Explosion explosion = player.worldObj.newExplosion(null, player.posX, player.posY, player.posZ, 10, true, true); player.attackEntityFrom(DamageSource.setExplosionSource(explosion), 5000); }else{ if (!player.worldObj.isRemote){ for (int i = 0; i < 25; ++i){ EntityCreeper creeper = new EntityCreeper(player.worldObj); - creeper.setPosition(player.posX + rand.nextInt(4) - 2, player.posY + 20, player.posZ + rand.nextInt(4) - 2); + creeper.setPosition(player.posX + player.worldObj.rand.nextInt(4) - 2, player.posY + 20, player.posZ + player.worldObj.rand.nextInt(4) - 2); player.worldObj.spawnEntityInWorld(creeper); } } diff --git a/src/main/java/am2/entities/ai/EntityAIManaDrainBolt.java b/src/main/java/am2/entities/ai/EntityAIManaDrainBolt.java index 17568afed..6b1ab2f0f 100644 --- a/src/main/java/am2/entities/ai/EntityAIManaDrainBolt.java +++ b/src/main/java/am2/entities/ai/EntityAIManaDrainBolt.java @@ -123,10 +123,14 @@ public void updateTask(){ */ private void doRangedAttack(){ //43% chance to "miss" - Random rand = new Random(); int chanceToMiss = entityHost.isPotionActive(Potion.moveSpeed) ? 10 : 43; - if (rand.nextInt(100) < chanceToMiss){ - AMCore.instance.proxy.particleManager.BoltFromPointToPoint(worldObj, entityHost.posX, entityHost.posY + entityHost.getEyeHeight(), entityHost.posZ, attackTarget.posX + rand.nextFloat() - 0.5f, attackTarget.posY + attackTarget.getEyeHeight() + rand.nextFloat() - 0.5f, attackTarget.posZ + rand.nextFloat() - 0.5f, 2, -1); + if (worldObj.rand.nextInt(100) < chanceToMiss){ + AMCore.instance.proxy.particleManager.BoltFromPointToPoint(worldObj, + entityHost.posX, entityHost.posY + entityHost.getEyeHeight(), + entityHost.posZ, attackTarget.posX + worldObj.rand.nextFloat() - 0.5f, + attackTarget.posY + attackTarget.getEyeHeight() + worldObj.rand.nextFloat() - 0.5f, + attackTarget.posZ + worldObj.rand.nextFloat() - 0.5f, + 2, -1); }else{ AMCore.instance.proxy.particleManager.BoltFromEntityToEntity(worldObj, entityHost, entityHost, attackTarget, this.damage, 2, -1); float manaDrained = this.manaDrainedPerCasterLevel * ExtendedProperties.For(attackTarget).getMagicLevel(); diff --git a/src/main/java/am2/guis/AM2FontRenderer.java b/src/main/java/am2/guis/AM2FontRenderer.java index e26f5228e..b8333c4a5 100644 --- a/src/main/java/am2/guis/AM2FontRenderer.java +++ b/src/main/java/am2/guis/AM2FontRenderer.java @@ -27,7 +27,7 @@ public class AM2FontRenderer{ * the height in pixels of default text */ public int FONT_HEIGHT = 10; - public Random fontRandom = new Random(); + public static final Random fontRandom = new Random(); /** * Array of the start/end column (in upper/lower nibble) for every glyph in the /font directory. diff --git a/src/main/java/am2/guis/AMGuiHelper.java b/src/main/java/am2/guis/AMGuiHelper.java index 8025c6aa9..30bb85212 100644 --- a/src/main/java/am2/guis/AMGuiHelper.java +++ b/src/main/java/am2/guis/AMGuiHelper.java @@ -76,6 +76,8 @@ private AMGuiHelper(){ //========================================= public EntityItem dummyItem; + + private static final Random rand = new Random(); public void blackoutArmorPiece(int index, int duration){ flashTimers[index] = flashDuration; @@ -471,7 +473,6 @@ public static void fractalLine2d(int src_x, int src_y, int dst_x, int dst_y, flo if (displace < fractalDetail){ line2d(src_x, src_y, dst_x, dst_y, zLevel, color); }else{ - Random rand = new Random(); int mid_x = (dst_x + src_x) / 2; int mid_y = (dst_y + src_y) / 2; mid_x += (rand.nextFloat() - 0.5) * displace; diff --git a/src/main/java/am2/illeffect/IllEffectDrainMana.java b/src/main/java/am2/illeffect/IllEffectDrainMana.java index ecb78d511..1ecd64226 100644 --- a/src/main/java/am2/illeffect/IllEffectDrainMana.java +++ b/src/main/java/am2/illeffect/IllEffectDrainMana.java @@ -24,8 +24,6 @@ public Map ApplyIllEffect(World world, int x, int y, int z HashMap toReturn = new HashMap(); if (world.isRemote) return toReturn; - Random rand = new Random(); - List located_players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x - 3, y - 3, z - 3, x + 3, y + 3, z + 3)); EntityPlayer[] players = located_players.toArray(new EntityPlayer[located_players.size()]); diff --git a/src/main/java/am2/illeffect/IllEffectSpark.java b/src/main/java/am2/illeffect/IllEffectSpark.java index e57219c33..d57c7b3a7 100644 --- a/src/main/java/am2/illeffect/IllEffectSpark.java +++ b/src/main/java/am2/illeffect/IllEffectSpark.java @@ -24,11 +24,10 @@ public IllEffectSeverity GetSeverity(){ public Map ApplyIllEffect(World world, int x, int y, int z){ HashMap toReturn = new HashMap(); if (world.isRemote) return toReturn; - Random rand = new Random(); List located_players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x - 3, y - 3, z - 3, x + 3, y + 3, z + 3)); EntityPlayer[] players = located_players.toArray(new EntityPlayer[located_players.size()]); if (players.length == 0) return toReturn; - EntityPlayer unlucky = players[rand.nextInt(players.length)]; + EntityPlayer unlucky = players[world.rand.nextInt(players.length)]; AMCore.instance.proxy.particleManager.BoltFromPointToPoint(world, x, y, z, unlucky.posX, unlucky.posY, unlucky.posZ, 4, -1); unlucky.attackEntityFrom(DamageSource.generic, 1); diff --git a/src/main/java/am2/illeffect/IllEffectSparkStorm.java b/src/main/java/am2/illeffect/IllEffectSparkStorm.java index 36c258b4d..1ab11214d 100644 --- a/src/main/java/am2/illeffect/IllEffectSparkStorm.java +++ b/src/main/java/am2/illeffect/IllEffectSparkStorm.java @@ -24,7 +24,6 @@ public IllEffectSeverity GetSeverity(){ public Map ApplyIllEffect(World world, int x, int y, int z){ HashMap toReturn = new HashMap(); if (world.isRemote) return toReturn; - Random rand = new Random(); List located_players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x - 3, y - 3, z - 3, x + 3, y + 3, z + 3)); EntityPlayer[] players = located_players.toArray(new EntityPlayer[located_players.size()]); if (players.length == 0) return toReturn; diff --git a/src/main/java/am2/illeffect/IllEffectsManager.java b/src/main/java/am2/illeffect/IllEffectsManager.java index f924dbf15..4fba2f836 100644 --- a/src/main/java/am2/illeffect/IllEffectsManager.java +++ b/src/main/java/am2/illeffect/IllEffectsManager.java @@ -10,12 +10,11 @@ public class IllEffectsManager{ private TreeMap DarkNexusBadThings; - private Random rand; public static IllEffectsManager instance = new IllEffectsManager(); + private static Random rand = new Random(); private IllEffectsManager(){ DarkNexusBadThings = new TreeMap(); - rand = new Random(); } public void ApplyRandomBadThing(TileEntity te, IllEffectSeverity maxSev, BadThingTypes type){ diff --git a/src/main/java/am2/items/ItemCrystalPhylactery.java b/src/main/java/am2/items/ItemCrystalPhylactery.java index 4b7735955..d15c5b9e2 100644 --- a/src/main/java/am2/items/ItemCrystalPhylactery.java +++ b/src/main/java/am2/items/ItemCrystalPhylactery.java @@ -189,7 +189,6 @@ public int getColorFromItemStack(ItemStack stack, int pass){ } public void getSpawnableEntities(World world){ - Random random = new Random(); for (Object clazz : EntityList.classToStringMapping.keySet()){ if (EntityCreature.class.isAssignableFrom((Class)clazz)){ try{ @@ -209,7 +208,7 @@ public void getSpawnableEntities(World world){ } if (!found){ //no spawn egg...pick random color? - color = random.nextInt(); + color = world.rand.nextInt(); } spawnableEntities.put((String)EntityList.classToStringMapping.get(clazz), color); } diff --git a/src/main/java/am2/lore/StoryManager.java b/src/main/java/am2/lore/StoryManager.java index 8a5e36da3..1c21cd4d1 100644 --- a/src/main/java/am2/lore/StoryManager.java +++ b/src/main/java/am2/lore/StoryManager.java @@ -8,13 +8,12 @@ public class StoryManager{ private ArrayList stories; - private Random rand; + private static final Random rand = new Random(); public static StoryManager INSTANCE = new StoryManager(); private StoryManager(){ stories = new ArrayList(); - rand = new Random(); } public void AddStory(String resourceFileName) throws IOException{ diff --git a/src/main/java/am2/navigation/PathNavigator.java b/src/main/java/am2/navigation/PathNavigator.java index 03f61ec1d..982ada604 100644 --- a/src/main/java/am2/navigation/PathNavigator.java +++ b/src/main/java/am2/navigation/PathNavigator.java @@ -15,7 +15,6 @@ public class PathNavigator{ private final EntityLivingBase pathEntity; private int PathUpdateTicks; private Point3D currentLocation; - private final Random rand; private Point3D lastLocation; private int ticksStuck; private Point3D longRangeWaypoint; @@ -29,7 +28,6 @@ public PathNavigator(EntityLivingBase entity){ currentWaypoint = null; pathData = null; pathIsLongRange = false; - rand = new Random(); } public boolean HasWaypoint(){ @@ -67,9 +65,9 @@ public void GenerateNewRandomWaypoint(World world, Entity entity){ int newX, newY, newZ; for (int i = 0; i < 5; ++i){ - newX = (int)Math.round(pathEntity.posX + (rand.nextDouble() * MaxPathDistance - (MaxPathDistance / 2))); - newY = (int)Math.round(pathEntity.posY + (rand.nextDouble() * 8 - (4))); - newZ = (int)Math.round(pathEntity.posZ + (rand.nextDouble() * MaxPathDistance - (MaxPathDistance / 2))); + newX = (int)Math.round(pathEntity.posX + (world.rand.nextDouble() * MaxPathDistance - (MaxPathDistance / 2))); + newY = (int)Math.round(pathEntity.posY + (world.rand.nextDouble() * 8 - (4))); + newZ = (int)Math.round(pathEntity.posZ + (world.rand.nextDouble() * MaxPathDistance - (MaxPathDistance / 2))); if (world.getBlock(newX, newY, newZ) == Blocks.air && newY > 5){ getEntityLocation(world); @@ -84,9 +82,9 @@ public void GenerateNewRandomWaypoint(World world, Entity entity, int minY, int int newX, newY, newZ; for (int i = 0; i < 5; ++i){ - newX = (int)Math.round(pathEntity.posX + (rand.nextDouble() * MaxPathDistance - (MaxPathDistance / 2))); - newY = (int)Math.round(minY + (rand.nextDouble() * (maxY - minY))); - newZ = (int)Math.round(pathEntity.posZ + (rand.nextDouble() * MaxPathDistance - (MaxPathDistance / 2))); + newX = (int)Math.round(pathEntity.posX + (world.rand.nextDouble() * MaxPathDistance - (MaxPathDistance / 2))); + newY = (int)Math.round(minY + (world.rand.nextDouble() * (maxY - minY))); + newZ = (int)Math.round(pathEntity.posZ + (world.rand.nextDouble() * MaxPathDistance - (MaxPathDistance / 2))); if (world.getBlock(newX, newY, newZ) == Blocks.air && newY > 5){ getEntityLocation(world); diff --git a/src/main/java/am2/particles/ParticleArcToEntity.java b/src/main/java/am2/particles/ParticleArcToEntity.java index 4668bc08f..53376a54a 100644 --- a/src/main/java/am2/particles/ParticleArcToEntity.java +++ b/src/main/java/am2/particles/ParticleArcToEntity.java @@ -43,8 +43,8 @@ public ParticleArcToEntity generateControlPoints(){ start.y + ((target.posY - start.y) / 3 * 2), start.z + ((target.posZ - start.z) / 3 * 2)); - double offsetX = (rand.nextFloat() * offsetFactor) - halfOffsetFactor; - double offsetZ = (rand.nextFloat() * offsetFactor) - halfOffsetFactor; + double offsetX = (particle.worldObj.rand.nextFloat() * offsetFactor) - halfOffsetFactor; + double offsetZ = (particle.worldObj.rand.nextFloat() * offsetFactor) - halfOffsetFactor; AMVector3 offset = new AMVector3(offsetX, 0, offsetZ); diff --git a/src/main/java/am2/particles/ParticleArcToPoint.java b/src/main/java/am2/particles/ParticleArcToPoint.java index de5f008f5..aec72464d 100644 --- a/src/main/java/am2/particles/ParticleArcToPoint.java +++ b/src/main/java/am2/particles/ParticleArcToPoint.java @@ -40,9 +40,9 @@ public ParticleArcToPoint generateControlPoints(){ start.y + ((target.y - start.y) / 3 * 2), start.z + ((target.z - start.z) / 3 * 2)); - double offsetX = (rand.nextFloat() * offsetFactor) - halfOffsetFactor; - double offsetZ = (rand.nextFloat() * offsetFactor) - halfOffsetFactor; - double offsetY = (rand.nextFloat() * offsetFactor) - halfOffsetFactor; + double offsetX = (particle.worldObj.rand.nextFloat() * offsetFactor) - halfOffsetFactor; + double offsetZ = (particle.worldObj.rand.nextFloat() * offsetFactor) - halfOffsetFactor; + double offsetY = (particle.worldObj.rand.nextFloat() * offsetFactor) - halfOffsetFactor; AMVector3 offset = new AMVector3(offsetX, offsetY, offsetZ); diff --git a/src/main/java/am2/particles/ParticleColorShift.java b/src/main/java/am2/particles/ParticleColorShift.java index a51dc8f0d..d2b8cafe9 100644 --- a/src/main/java/am2/particles/ParticleColorShift.java +++ b/src/main/java/am2/particles/ParticleColorShift.java @@ -74,9 +74,9 @@ public ParticleColorShift SetEndOnReachingTargetColor(){ } private void GenerateNextColorTarget(){ - targetRed = (rand.nextFloat() * (maxRed - minRed)) + minRed; - targetGreen = (rand.nextFloat() * (maxGreen - minGreen)) + minGreen; - targetBlue = (rand.nextFloat() * (maxBlue - minBlue)) + minBlue; + targetRed = (particle.worldObj.rand.nextFloat() * (maxRed - minRed)) + minRed; + targetGreen = (particle.worldObj.rand.nextFloat() * (maxGreen - minGreen)) + minGreen; + targetBlue = (particle.worldObj.rand.nextFloat() * (maxBlue - minBlue)) + minBlue; } @Override diff --git a/src/main/java/am2/particles/ParticleController.java b/src/main/java/am2/particles/ParticleController.java index 4e969ccd8..98929fe60 100644 --- a/src/main/java/am2/particles/ParticleController.java +++ b/src/main/java/am2/particles/ParticleController.java @@ -7,7 +7,6 @@ public abstract class ParticleController{ protected AMParticle particle; - protected Random rand; protected int priority; protected boolean exclusive; @@ -29,7 +28,6 @@ public abstract class ParticleController{ public ParticleController(AMParticle particleEffect, int priority, boolean exclusive){ this.particle = particleEffect; - rand = new Random(); this.priority = priority; this.exclusive = exclusive; this.killParticleOnFinish = false; diff --git a/src/main/java/am2/particles/ParticleFloatUpward.java b/src/main/java/am2/particles/ParticleFloatUpward.java index f07eaa31d..c5e3f9646 100644 --- a/src/main/java/am2/particles/ParticleFloatUpward.java +++ b/src/main/java/am2/particles/ParticleFloatUpward.java @@ -21,7 +21,7 @@ public void doUpdate(){ this.finish(); return; } - particle.moveEntity((rand.nextDouble() * jitter) - halfJitter, speed, (rand.nextDouble() * jitter) - halfJitter); + particle.moveEntity((particle.worldObj.rand.nextDouble() * jitter) - halfJitter, speed, (particle.worldObj.rand.nextDouble() * jitter) - halfJitter); } @Override diff --git a/src/main/java/am2/particles/ParticleManagerClient.java b/src/main/java/am2/particles/ParticleManagerClient.java index 6d405ac7b..3eed567f0 100644 --- a/src/main/java/am2/particles/ParticleManagerClient.java +++ b/src/main/java/am2/particles/ParticleManagerClient.java @@ -26,7 +26,6 @@ public class ParticleManagerClient extends ParticleManagerServer{ public static final byte PKT_BOLT_PT_PT = 63; public static final byte PKT_BEAM_ENT_ENT = 62; public static final byte PKT_BEAM_PT_PT = 61; - private final Random rand = new Random(); private final ParticleRenderer particleRenderer; public ParticleManagerClient(){ @@ -446,15 +445,32 @@ public void spawnAuraParticles(EntityLivingBase ent){ if (Minecraft.getMinecraft().thePlayer != ent || Minecraft.getMinecraft().gameSettings.thirdPersonView > 0){ if (AMParticle.particleTypes[particleIndex].startsWith("lightning_bolts")){ int type = Integer.parseInt(new String(new char[]{AMParticle.particleTypes[particleIndex].charAt(AMParticle.particleTypes[particleIndex].length() - 1)})); - if (rand.nextInt(100) < 90){ - BoltFromPointToPoint(ent.worldObj, ent.posX + (rand.nextFloat() - 0.5f), ent.posY + ent.getEyeHeight() - ent.height + (rand.nextFloat() * ent.height), ent.posZ + (rand.nextFloat() - 0.5f), ent.posX + (rand.nextFloat() - 0.5f), ent.posY + ent.getEyeHeight() - ent.height + (rand.nextFloat() * ent.height), ent.posZ + (rand.nextFloat() - 0.5f), type, -1); + if (ent.worldObj.rand.nextInt(100) < 90){ + BoltFromPointToPoint(ent.worldObj, + ent.posX + (ent.worldObj.rand.nextFloat() - 0.5f), + ent.posY + ent.getEyeHeight() - ent.height + (ent.worldObj.rand.nextFloat() * ent.height), + ent.posZ + (ent.worldObj.rand.nextFloat() - 0.5f), + ent.posX + (ent.worldObj.rand.nextFloat() - 0.5f), + ent.posY + ent.getEyeHeight() - ent.height + (ent.worldObj.rand.nextFloat() * ent.height), + ent.posZ + (ent.worldObj.rand.nextFloat() - 0.5f), + type, -1); }else{ - BoltFromPointToPoint(ent.worldObj, ent.posX, ent.posY + ent.getEyeHeight() - 0.4, ent.posZ, ent.posX + (rand.nextFloat() * 10 - 5), ent.posY + (rand.nextFloat() * 10 - 5), ent.posZ + (rand.nextFloat() * 10 - 5), type, -1); + BoltFromPointToPoint(ent.worldObj, + ent.posX, + ent.posY + ent.getEyeHeight() - 0.4, + ent.posZ, + ent.posX + (ent.worldObj.rand.nextFloat() * 10 - 5), + ent.posY + (ent.worldObj.rand.nextFloat() * 10 - 5), + ent.posZ + (ent.worldObj.rand.nextFloat() * 10 - 5), + type, -1); } }else{ int offset = 0; for (int i = 0; i < particleQuantity; ++i){ - AMParticle effect = spawn(ent.worldObj, AMParticle.particleTypes[particleIndex], ent.posX + (rand.nextFloat() - 0.5f), ent.posY + ent.getEyeHeight() - 0.5f + offset - (rand.nextFloat() * 0.5), ent.posZ + (rand.nextFloat() - 0.5f)); + AMParticle effect = spawn(ent.worldObj, AMParticle.particleTypes[particleIndex], + ent.posX + (ent.worldObj.rand.nextFloat() - 0.5f), + ent.posY + ent.getEyeHeight() - 0.5f + offset - (ent.worldObj.rand.nextFloat() * 0.5), + ent.posZ + (ent.worldObj.rand.nextFloat() - 0.5f)); if (effect != null){ effect.setIgnoreMaxAge(false); effect.setMaxAge(40); @@ -463,7 +479,7 @@ public void spawnAuraParticles(EntityLivingBase ent){ effect.noClip = false; if (!particleDefaultColor){ if (particleRandomColor){ - effect.setRGBColorF(rand.nextFloat(), rand.nextFloat(), rand.nextFloat()); + effect.setRGBColorF(ent.worldObj.rand.nextFloat(), ent.worldObj.rand.nextFloat(), ent.worldObj.rand.nextFloat()); }else{ effect.setRGBColorI(particleColor); } @@ -506,7 +522,6 @@ public void spawnAuraParticles(EntityLivingBase ent){ @Override public void spawnBuffParticles(EntityLivingBase entityliving){ - Random rand = new Random(); World world = entityliving.worldObj; if (!world.isRemote) return; @@ -517,10 +532,14 @@ public void spawnBuffParticles(EntityLivingBase entityliving){ for (int i = -radius; i <= radius; ++i){ for (int j = -radius; j <= radius; ++j){ for (int k = -radius; k <= radius; ++k){ - if (entityliving.worldObj.getBlock((int)entityliving.posX + i, (int)entityliving.posY + j, (int)entityliving.posZ + k) == Blocks.air && entityliving.worldObj.getBlockLightValue((int)entityliving.posX + i, (int)entityliving.posY + j, (int)entityliving.posZ + k) <= 7){ - AMParticle effect = spawn(world, "hr_sparkles_1", (int)entityliving.posX - 1 + i + (rand.nextDouble() * 3), (int)entityliving.posY - 1 + j + (rand.nextDouble() * 3), (int)entityliving.posZ - 1 + k + (rand.nextDouble() * 3)); + if (entityliving.worldObj.getBlock((int)entityliving.posX + i, (int)entityliving.posY + j, (int)entityliving.posZ + k) == Blocks.air + && entityliving.worldObj.getBlockLightValue((int)entityliving.posX + i, (int)entityliving.posY + j, (int)entityliving.posZ + k) <= 7){ + AMParticle effect = spawn(world, "hr_sparkles_1", + (int)entityliving.posX - 1 + i + (world.rand.nextDouble() * 3), + (int)entityliving.posY - 1 + j + (world.rand.nextDouble() * 3), + (int)entityliving.posZ - 1 + k + (world.rand.nextDouble() * 3)); if (effect != null){ - effect.setRGBColorF(rand.nextFloat() * 0.4f + 0.3f, 0.6f, rand.nextFloat() * 0.4f + 0.6f); + effect.setRGBColorF(world.rand.nextFloat() * 0.4f + 0.3f, 0.6f, world.rand.nextFloat() * 0.4f + 0.6f); effect.setIgnoreMaxAge(false); effect.setMaxAge(40); effect.AddParticleController(new ParticleFloatUpward(effect, 0.01f, 0.01f, 1, false)); diff --git a/src/main/java/am2/particles/ParticleManagerServer.java b/src/main/java/am2/particles/ParticleManagerServer.java index 1c5d6c5f2..f0ef7c7d8 100644 --- a/src/main/java/am2/particles/ParticleManagerServer.java +++ b/src/main/java/am2/particles/ParticleManagerServer.java @@ -23,7 +23,6 @@ public class ParticleManagerServer{ public static final byte PKT_ARC_PT_PT = 58; public static final byte PKT_ARC_PT_ENT = 57; public static final byte PKT_ARC_ENT_ENT = 56; - private final Random rand = new Random(); public Object spawn(World world, String name, double x, double y, double z){ return null; diff --git a/src/main/java/am2/particles/ParticleOrbitEntity.java b/src/main/java/am2/particles/ParticleOrbitEntity.java index 5156a9230..df4053dd7 100644 --- a/src/main/java/am2/particles/ParticleOrbitEntity.java +++ b/src/main/java/am2/particles/ParticleOrbitEntity.java @@ -22,10 +22,10 @@ public final class ParticleOrbitEntity extends ParticleController{ public ParticleOrbitEntity(AMParticle particleEffect, Entity orbitTarget, double orbitSpeed, int priority, boolean exclusive){ super(particleEffect, priority, exclusive); target = orbitTarget; - orbitAngle = rand.nextInt(360); - rotateClockwise = rand.nextBoolean(); + orbitAngle = particle.worldObj.rand.nextInt(360); + rotateClockwise = particle.worldObj.rand.nextBoolean(); generateNewTargetY(); - targetDistance = 1 + (rand.nextDouble() * 0.5); + targetDistance = 1 + (particle.worldObj.rand.nextDouble() * 0.5); this.orbitSpeed = orbitSpeed; } @@ -41,7 +41,7 @@ public ParticleOrbitEntity SetTargetDistance(double targetDistance){ private void generateNewTargetY(){ if (target != null){ - targetY = (new Random().nextDouble() * target.height); + targetY = particle.worldObj.rand.nextDouble() * target.height; }else{ targetY = 0; } @@ -49,7 +49,7 @@ private void generateNewTargetY(){ private void generateNewDistance(){ if (target != null){ - targetDistance = new Random().nextDouble() * 2; + targetDistance = particle.worldObj.rand.nextDouble() * 2; }else{ targetDistance = 0; } diff --git a/src/main/java/am2/particles/ParticleOrbitPoint.java b/src/main/java/am2/particles/ParticleOrbitPoint.java index 72902409f..4d53d1e41 100644 --- a/src/main/java/am2/particles/ParticleOrbitPoint.java +++ b/src/main/java/am2/particles/ParticleOrbitPoint.java @@ -32,10 +32,10 @@ public CoordStore(double x, double y, double z){ public ParticleOrbitPoint(AMParticle particleEffect, double orbitX, double orbitY, double orbitZ, int priority, boolean exclusive){ super(particleEffect, priority, exclusive); target = new CoordStore(orbitX, orbitY, orbitZ); - orbitAngle = rand.nextInt(360); - rotateClockwise = rand.nextInt(10) < 5; + orbitAngle = particle.worldObj.rand.nextInt(360); + rotateClockwise = particle.worldObj.rand.nextInt(10) < 5; generateNewTargetY(); - targetDistance = 1 + (rand.nextDouble() * 0.5); + targetDistance = 1 + (particle.worldObj.rand.nextDouble() * 0.5); } public ParticleOrbitPoint setOrbitY(double orbitY){ @@ -73,7 +73,7 @@ public ParticleOrbitPoint SetShrinkingOrbit(double shrinkSpeed, double newTarget private void generateNewTargetY(){ if (target != null){ - targetY = (new Random().nextDouble() * 2); + targetY = particle.worldObj.rand.nextDouble() * 2; }else{ targetY = 0; } @@ -81,7 +81,7 @@ private void generateNewTargetY(){ private void generateNewDistance(){ if (target != null){ - targetDistance = new Random().nextDouble() * 2; + targetDistance = particle.worldObj.rand.nextDouble() * 2; }else{ targetDistance = 0; } diff --git a/src/main/java/am2/particles/ParticlePendulum.java b/src/main/java/am2/particles/ParticlePendulum.java index bd06ad73a..0a7457fa6 100644 --- a/src/main/java/am2/particles/ParticlePendulum.java +++ b/src/main/java/am2/particles/ParticlePendulum.java @@ -27,7 +27,7 @@ public ParticlePendulum setStopOnCollide(boolean stop){ } private void generateNewAngle(){ - angle = Math.toRadians(rand.nextInt(360)); + angle = Math.toRadians(particle.worldObj.rand.nextInt(360)); } @Override diff --git a/src/main/java/am2/spell/SpellHelper.java b/src/main/java/am2/spell/SpellHelper.java index ce141b5a4..9fffe606f 100644 --- a/src/main/java/am2/spell/SpellHelper.java +++ b/src/main/java/am2/spell/SpellHelper.java @@ -45,10 +45,7 @@ public class SpellHelper{ public static final SpellHelper instance = new SpellHelper(); - private final Random rand; - private SpellHelper(){ - rand = new Random(); } public SpellCastResult applyStageToGround(ItemStack stack, EntityLivingBase caster, World world, int blockX, int blockY, int blockZ, int blockFace, double impactX, double impactY, double impactZ, int stage, boolean consumeMBR){ @@ -81,7 +78,7 @@ public SpellCastResult applyStageToGround(ItemStack stack, EntityLivingBase cast } } } - component.spawnParticles(world, blockX, blockY, blockZ, caster, caster, rand, color); + component.spawnParticles(world, blockX, blockY, blockZ, caster, caster, world.rand, color); } if (consumeMBR) SpellUtils.instance.doAffinityShift(caster, component, stageShape); @@ -118,7 +115,7 @@ public SpellCastResult applyStageToEntity(ItemStack stack, EntityLivingBase cast } } } - component.spawnParticles(world, target.posX, target.posY + target.getEyeHeight(), target.posZ, caster, target, rand, color); + component.spawnParticles(world, target.posX, target.posY + target.getEyeHeight(), target.posZ, caster, target, world.rand, color); } if (shiftAffinityAndXP) SpellUtils.instance.doAffinityShift(caster, component, stageShape); diff --git a/src/main/java/am2/spell/components/Accelerate.java b/src/main/java/am2/spell/components/Accelerate.java index 4ee547e04..f0bdcd89a 100644 --- a/src/main/java/am2/spell/components/Accelerate.java +++ b/src/main/java/am2/spell/components/Accelerate.java @@ -19,14 +19,12 @@ public class Accelerate implements ISpellComponent{ - private final Random rand = new Random(); - @Override public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int blocky, int blockz, int blockFace, double impactX, double impactY, double impactZ, EntityLivingBase caster){ - if (rand.nextDouble() < 0.5){ + if (world.rand.nextDouble() < 0.5){ Block block = world.getBlock(blockx, blocky, blockz); if (block != Blocks.air){ - block.updateTick(world, blocky, blocky, blockz, rand); + block.updateTick(world, blocky, blocky, blockz, world.rand); } } return true; diff --git a/src/main/java/am2/spell/components/Blink.java b/src/main/java/am2/spell/components/Blink.java index 19308b6d0..8fe13c4cf 100644 --- a/src/main/java/am2/spell/components/Blink.java +++ b/src/main/java/am2/spell/components/Blink.java @@ -53,8 +53,6 @@ public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase double d = motionX, d1 = motionY, d2 = motionZ; - Random rand = new Random(); - float f2 = MathHelper.sqrt_double(d * d + d1 * d1 + d2 * d2); d /= f2; d1 /= f2; @@ -235,8 +233,6 @@ public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase } - Random rnd = new Random(); - if (world.isRemote && astralBarrierBlocked && coordsValid){ ExtendedProperties.For((EntityLivingBase)target).astralBarrierBlocked = true; if (finalBlocker != null){ diff --git a/src/main/java/am2/spell/components/Grow.java b/src/main/java/am2/spell/components/Grow.java index 866986dd0..3fb9257eb 100644 --- a/src/main/java/am2/spell/components/Grow.java +++ b/src/main/java/am2/spell/components/Grow.java @@ -32,7 +32,6 @@ public class Grow implements ISpellComponent{ - private final Random random = new Random(); private final static ArrayList growableAMflowers = new ArrayList(Arrays.asList( BlocksCommonProxy.cerublossom, BlocksCommonProxy.desertNova, BlocksCommonProxy.wakebloom, BlocksCommonProxy.aum, BlocksCommonProxy.tarmaRoot)); @@ -50,7 +49,7 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl } //EoD: Spawn AM2 flowers with 3% chance. This has to be the first one in the list to override all others - if (random.nextInt(100) < 3 && block.isNormalCube() && + if (world.rand.nextInt(100) < 3 && block.isNormalCube() && (world.getBlock(blockx, blocky + 1, blockz).isAir(null, 0, 0, 0) || world.getBlock(blockx, blocky + 1, blockz) == Blocks.tallgrass)){ // shuffle the flower list every time we want to try to find one. Collections.shuffle(growableAMflowers); @@ -68,7 +67,7 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl //Grow huge mushrooms 10% of the time. if (block instanceof BlockMushroom){ - if (!world.isRemote && random.nextInt(10) < 1){ + if (!world.isRemote && world.rand.nextInt(10) < 1){ ((BlockMushroom)block).func_149884_c(world, blockx, blocky, blockz, world.rand); } @@ -79,7 +78,7 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl //If the spell is executed in water, check if we have space for a wakebloom above and create one 3% of the time. if (block == Blocks.water){ if (world.getBlock(blockx, blocky + 1, blockz) == Blocks.air){ - if (!world.isRemote && random.nextInt(100) < 3){ + if (!world.isRemote && world.rand.nextInt(100) < 3){ world.setBlock(blockx, blocky + 1, blockz, BlocksCommonProxy.wakebloom); } return true; @@ -89,7 +88,7 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl //EoD: If there is already tallgrass present, let's grow it further 20% of the time. if (block == Blocks.tallgrass){ if (Blocks.tallgrass.canBlockStay(world, blockx, blocky + 1, blockz)){ - if (!world.isRemote && random.nextInt(10) < 2){ + if (!world.isRemote && world.rand.nextInt(10) < 2){ world.setBlock(blockx, blocky, blockz, Blocks.tallgrass, 1, 2); } return true; @@ -100,7 +99,7 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl // This works only on podzol in vanilla MC. if (block == Blocks.deadbush){ if (Blocks.tallgrass.canBlockStay(world, blockx, blocky, blockz)){ - if (!world.isRemote && random.nextInt(10) < 2){ + if (!world.isRemote && world.rand.nextInt(10) < 2){ world.setBlock(blockx, blocky, blockz, Blocks.tallgrass, 1, 2); } return true; @@ -114,7 +113,7 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl //AMCore.log.getLogger().info("Grow component found IGrowable"); if (igrowable.func_149851_a(world, blockx, blocky, blockz, world.isRemote)){ - if (!world.isRemote && random.nextInt(10) < 3){ + if (!world.isRemote && world.rand.nextInt(10) < 3){ if (igrowable.func_149852_a(world, world.rand, blockx, blocky, blockz)){ igrowable.func_149853_b(world, world.rand, blockx, blocky, blockz); } diff --git a/src/main/java/am2/spell/components/RandomTeleport.java b/src/main/java/am2/spell/components/RandomTeleport.java index 74588cc5e..4d4c396b7 100644 --- a/src/main/java/am2/spell/components/RandomTeleport.java +++ b/src/main/java/am2/spell/components/RandomTeleport.java @@ -23,8 +23,6 @@ public class RandomTeleport implements ISpellComponent{ - private final Random rand = new Random(); - @Override public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int blocky, int blockz, int blockFace, double impactX, double impactY, double impactZ, EntityLivingBase caster){ return false; @@ -40,7 +38,7 @@ private AMVector3 getRandomTeleportLocation(World world, ItemStack stack, Entity AMVector3 origin = new AMVector3(target); float maxDist = 9; maxDist = (float)SpellUtils.instance.getModifiedDouble_Mul(maxDist, stack, caster, target, world, 0, SpellModifiers.RANGE); - origin.add(new AMVector3((rand.nextDouble() - 0.5) * maxDist, (rand.nextDouble() - 0.5) * maxDist, (rand.nextDouble() - 0.5) * maxDist)); + origin.add(new AMVector3((world.rand.nextDouble() - 0.5) * maxDist, (world.rand.nextDouble() - 0.5) * maxDist, (world.rand.nextDouble() - 0.5) * maxDist)); return origin; } @@ -114,7 +112,7 @@ public ItemStack[] reagents(EntityLivingBase caster){ @Override public void spawnParticles(World world, double x, double y, double z, EntityLivingBase caster, Entity target, Random rand, int colorModifier){ - world.spawnParticle("portal", target.posX + (this.rand.nextDouble() - 0.5D) * target.width, target.posY + this.rand.nextDouble() * target.height - 0.25D, target.posZ + (this.rand.nextDouble() - 0.5D) * target.width, (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(), (this.rand.nextDouble() - 0.5D) * 2.0D); + world.spawnParticle("portal", target.posX + (rand.nextDouble() - 0.5D) * target.width, target.posY + rand.nextDouble() * target.height - 0.25D, target.posZ + (rand.nextDouble() - 0.5D) * target.width, (rand.nextDouble() - 0.5D) * 2.0D, -rand.nextDouble(), (rand.nextDouble() - 0.5D) * 2.0D); } @Override diff --git a/src/main/java/am2/spell/components/Storm.java b/src/main/java/am2/spell/components/Storm.java index 119a489c8..78b4242dc 100644 --- a/src/main/java/am2/spell/components/Storm.java +++ b/src/main/java/am2/spell/components/Storm.java @@ -24,8 +24,6 @@ public class Storm implements ISpellComponent{ - private final Random rand = new Random(); - @Override public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int blocky, int blockz, int blockFace, double impactX, double impactY, double impactZ, EntityLivingBase caster){ applyEffect(caster, world); @@ -43,10 +41,10 @@ private void applyEffect(EntityLivingBase caster, World world){ if (rainStrength > 0.9D){ if (!world.isRemote){ int xzradius = 50; - int random = rand.nextInt(100); + int random = world.rand.nextInt(100); if (random < 20){ - int randPosX = (int)caster.posX + rand.nextInt(xzradius * 2) - xzradius; - int randPosZ = (int)caster.posZ + rand.nextInt(xzradius * 2) - xzradius; + int randPosX = (int)caster.posX + world.rand.nextInt(xzradius * 2) - xzradius; + int randPosZ = (int)caster.posZ + world.rand.nextInt(xzradius * 2) - xzradius; int posY = (int)caster.posY; while (!world.canBlockSeeTheSky(randPosX, posY, randPosZ)){ @@ -63,7 +61,7 @@ private void applyEffect(EntityLivingBase caster, World world){ if (entities.size() <= 0){ return; } - Entity target = entities.get(rand.nextInt(entities.size())); + Entity target = entities.get(world.rand.nextInt(entities.size())); if (target != null && world.canBlockSeeTheSky((int)target.posX, (int)target.posY, (int)target.posZ)){ if (caster instanceof EntityPlayer){ target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)caster), 1); From a34bc5f70a2b6f535370961982a5b0458e772960 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sat, 28 Nov 2015 00:37:05 +0100 Subject: [PATCH 08/34] Fixed compile error with canTriggerWalking() Might be due to different forge version? --- src/main/java/am2/entities/EntityBroom.java | 2 +- src/main/java/am2/entities/EntityDryad.java | 6 +++--- src/main/java/am2/entities/EntityFlicker.java | 2 +- src/main/java/am2/particles/AMParticle.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/am2/entities/EntityBroom.java b/src/main/java/am2/entities/EntityBroom.java index 74d9d720c..984715ebc 100644 --- a/src/main/java/am2/entities/EntityBroom.java +++ b/src/main/java/am2/entities/EntityBroom.java @@ -40,7 +40,7 @@ public boolean doesEntityNotTriggerPressurePlate(){ } @Override - protected boolean canTriggerWalking(){ + public boolean canTriggerWalking(){ return false; } diff --git a/src/main/java/am2/entities/EntityDryad.java b/src/main/java/am2/entities/EntityDryad.java index 234a532fa..453b4217e 100644 --- a/src/main/java/am2/entities/EntityDryad.java +++ b/src/main/java/am2/entities/EntityDryad.java @@ -37,7 +37,7 @@ public boolean isAIEnabled(){ } @Override - protected boolean canTriggerWalking(){ + public boolean canTriggerWalking(){ return false; } @@ -64,10 +64,10 @@ public void onUpdate(){ if (!world.isRemote || world == null){ return; } - if (new Random().nextInt(100) == 3){ + if (worldObj.rand.nextInt(100) == 3){ AMParticle effect = (AMParticle)AMCore.instance.proxy.particleManager.spawn(world, "hr_sparkles_1", this.posX, this.posY + 2, this.posZ); if (effect != null){ - effect.AddParticleController(new ParticleOrbitEntity(effect, this, new Random().nextDouble() * 0.2 + 0.2, 1, false)); + effect.AddParticleController(new ParticleOrbitEntity(effect, this, worldObj.rand.nextDouble() * 0.2 + 0.2, 1, false)); effect.setIgnoreMaxAge(false); effect.setRGBColorF(0.1f, 0.8f, 0.1f); } diff --git a/src/main/java/am2/entities/EntityFlicker.java b/src/main/java/am2/entities/EntityFlicker.java index f438df7b1..60cef82dd 100644 --- a/src/main/java/am2/entities/EntityFlicker.java +++ b/src/main/java/am2/entities/EntityFlicker.java @@ -98,7 +98,7 @@ public boolean canBreatheUnderwater(){ } @Override - protected boolean canTriggerWalking(){ + public boolean canTriggerWalking(){ return false; } diff --git a/src/main/java/am2/particles/AMParticle.java b/src/main/java/am2/particles/AMParticle.java index f3b5b8398..0d97b084e 100644 --- a/src/main/java/am2/particles/AMParticle.java +++ b/src/main/java/am2/particles/AMParticle.java @@ -95,7 +95,7 @@ public boolean isBurning(){ } @Override - protected boolean canTriggerWalking(){ + public boolean canTriggerWalking() { return false; } From 30427049c9a641e4bfc9c2f5862adfb7f8d086e6 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sat, 28 Nov 2015 00:38:35 +0100 Subject: [PATCH 09/34] Improved client network upload --- .../playerextensions/ExtendedProperties.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/am2/playerextensions/ExtendedProperties.java b/src/main/java/am2/playerextensions/ExtendedProperties.java index 2fac84fc0..1a7f050f3 100644 --- a/src/main/java/am2/playerextensions/ExtendedProperties.java +++ b/src/main/java/am2/playerextensions/ExtendedProperties.java @@ -37,7 +37,6 @@ import java.util.ArrayList; import java.util.Iterator; -import java.util.Random; public class ExtendedProperties implements IExtendedProperties, IExtendedEntityProperties{ private EntityLivingBase entity; @@ -990,7 +989,7 @@ public void init(Entity entity, World world){ updateFlags = 0; - ticksToSync = new Random().nextInt(syncTickDelay); + ticksToSync = world.rand.nextInt(syncTickDelay); hasInitialized = true; } @@ -1037,9 +1036,20 @@ public void addBurnout(float burnout){ burnout *= 0.75f; this.setCurrentFatigue(currentFatigue + burnout); } - + + @Override + public String toString() { + try { + return hashCode() + " " + entity; + } catch(Exception exception) { + return hashCode() + " (error)"; + } + } + public void handleExtendedPropertySync(){ - if (!this.getHasDoneFullSync()) this.setFullSync(); + if (!entity.worldObj.isRemote && !this.getHasDoneFullSync()) { + this.setFullSync(); + } if (!entity.worldObj.isRemote && this.getHasUpdate()){ byte[] data = this.getUpdateData(); From be49c3d8bbd6fb5fb84a18a2215739a72eb32f0b Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sat, 28 Nov 2015 01:48:33 +0100 Subject: [PATCH 10/34] Integrated the random optimisation --- .../TileEntityArcaneReconstructor.java | 18 +++++++++++------- .../tileentities/TileEntityCalefactor.java | 12 ++++++------ .../TileEntityEssenceConduit.java | 19 +++++++++++-------- .../TileEntityParticleEmitter.java | 3 --- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/main/java/am2/blocks/tileentities/TileEntityArcaneReconstructor.java b/src/main/java/am2/blocks/tileentities/TileEntityArcaneReconstructor.java index 5a5b6637c..dbe8d574a 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityArcaneReconstructor.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityArcaneReconstructor.java @@ -42,11 +42,12 @@ public class TileEntityArcaneReconstructor extends TileEntityAMPower implements private EntityLiving dummyEntity; - private final AMVector3 outerRingRotationSpeeds; - private final AMVector3 middleRingRotationSpeeds; - private final AMVector3 innerRingRotationSpeeds; + private AMVector3 outerRingRotationSpeeds; + private AMVector3 middleRingRotationSpeeds; + private AMVector3 innerRingRotationSpeeds; private static final int SLOT_ACTIVE = 3; + private boolean isFirstTick = true; public TileEntityArcaneReconstructor(){ super(500); @@ -58,10 +59,6 @@ public TileEntityArcaneReconstructor(){ middleRingRotation = new AMVector3(0, 0, 0); innerRingRotation = new AMVector3(0, 0, 0); - outerRingRotationSpeeds = new AMVector3(worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2); - middleRingRotationSpeeds = new AMVector3(worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2); - innerRingRotationSpeeds = new AMVector3(worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2); - } @Override @@ -86,6 +83,13 @@ public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt){ @Override public void updateEntity(){ + if (isFirstTick) { + outerRingRotationSpeeds = new AMVector3(worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2); + middleRingRotationSpeeds = new AMVector3(worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2); + innerRingRotationSpeeds = new AMVector3(worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2); + isFirstTick = false; + } + if (PowerNodeRegistry.For(this.worldObj).checkPower(this, this.getRepairCost()) && repairCounter++ % getRepairRate() == 0){ if (!queueRepairableItem()){ if (performRepair()){ diff --git a/src/main/java/am2/blocks/tileentities/TileEntityCalefactor.java b/src/main/java/am2/blocks/tileentities/TileEntityCalefactor.java index d6527d049..2b89ded11 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityCalefactor.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityCalefactor.java @@ -32,7 +32,7 @@ public class TileEntityCalefactor extends TileEntityAMPower implements IInventor private ItemStack calefactorItemStacks[]; private float rotationX, rotationY, rotationZ; - private final float rotationStepX, rotationStepY, rotationStepZ; + private float rotationStepX; private final short baseCookTime = 220; //default to the same as a standard furnace private short timeSpentCooking = 0; private final float basePowerConsumedPerTickCooking = 0.85f; @@ -40,14 +40,12 @@ public class TileEntityCalefactor extends TileEntityAMPower implements IInventor private boolean isCooking; private static final byte PKT_PRG_UPDATE = 1; + private boolean isFirstTick = true; public TileEntityCalefactor(){ super(100); calefactorItemStacks = new ItemStack[getSizeInventory()]; - rotationStepX = worldObj.rand.nextFloat() * 0.03f - 0.015f; - rotationStepY = worldObj.rand.nextFloat() * 0.03f - 0.015f; - rotationStepZ = worldObj.rand.nextFloat() * 0.03f - 0.015f; isCooking = false; } @@ -238,7 +236,10 @@ private boolean isSmelting(){ @Override public void updateEntity(){ super.updateEntity(); - boolean didSmeltItem = false; + if (isFirstTick) { + rotationStepX = worldObj.rand.nextFloat() * 0.03f - 0.015f; + isFirstTick = false; + } if (this.worldObj.isRemote){ incrementRotations(); @@ -286,7 +287,6 @@ public void updateEntity(){ if (this.timeSpentCooking >= getModifiedCookTime()){ if (!this.worldObj.isRemote){ this.smeltItem(); - didSmeltItem = true; }else{ worldObj.playSound(xCoord, yCoord, zCoord, "arsmagica2:misc.calefactor.burn", 0.2f, 1.0f, true); } diff --git a/src/main/java/am2/blocks/tileentities/TileEntityEssenceConduit.java b/src/main/java/am2/blocks/tileentities/TileEntityEssenceConduit.java index 0cdfb1450..f77b09714 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityEssenceConduit.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityEssenceConduit.java @@ -15,23 +15,26 @@ public class TileEntityEssenceConduit extends TileEntityAMPower{ private float rotationIncrementX; private float rotationIncrementY; private float rotationIncrementZ; + + private boolean isFirstTick = false; public TileEntityEssenceConduit(){ super(1); - rotationX = worldObj.rand.nextInt(360); - rotationY = worldObj.rand.nextInt(360); - rotationZ = worldObj.rand.nextInt(360); redstonePowered = false; - - rotationIncrementX = worldObj.rand.nextFloat() * 0.002f + 0.005f; - rotationIncrementY = worldObj.rand.nextFloat() * 0.002f + 0.005f; - rotationIncrementZ = worldObj.rand.nextFloat() * 0.002f + 0.005f; - } @Override public void updateEntity(){ + if (isFirstTick) { + rotationX = worldObj.rand.nextInt(360); + rotationY = worldObj.rand.nextInt(360); + rotationZ = worldObj.rand.nextInt(360); + rotationIncrementX = worldObj.rand.nextFloat() * 0.002f + 0.005f; + rotationIncrementY = worldObj.rand.nextFloat() * 0.002f + 0.005f; + rotationIncrementZ = worldObj.rand.nextFloat() * 0.002f + 0.005f; + isFirstTick = false; + } if (worldObj != null && worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){ redstonePowered = true; }else{ diff --git a/src/main/java/am2/blocks/tileentities/TileEntityParticleEmitter.java b/src/main/java/am2/blocks/tileentities/TileEntityParticleEmitter.java index 7b2146f6a..aa65ebaf4 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityParticleEmitter.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityParticleEmitter.java @@ -32,8 +32,6 @@ public class TileEntityParticleEmitter extends TileEntity{ private float speed; private boolean hasReceivedFullUpdate = false; - private int fullUpdateDelayTicks; - private int updateCounter = 0; private int spawnTicks = 0; private int showTicks = 0; @@ -51,7 +49,6 @@ public TileEntityParticleEmitter(){ randomColor = false; show = true; forceShow = false; - fullUpdateDelayTicks = worldObj.rand.nextInt(40); } @Override From 65f6c453de60e05c243054a1fae2b8bcd9f5e054 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sat, 28 Nov 2015 02:45:22 +0100 Subject: [PATCH 11/34] Updated forge to 1492 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 6f9d15cae..950b0f544 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ group= "am2" // http://maven.apache.org/guides/mini/guide-naming-conventions.htm archivesBaseName = "AM2" minecraft { - version = "1.7.10-10.13.4.1448-1.7.10" + version = "1.7.10-10.13.4.1492-1.7.10" runDir = "run" //mappings = "stable_12" //uncomment this line to use newest Forge mappings. Needs a lot of rework. } From dee8b38227441315fb489058fe218f78a1a88ad7 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sat, 28 Nov 2015 04:12:55 +0100 Subject: [PATCH 12/34] Fixed arcane reconstructor animation in SMP Added arcane reconstructor deactivation when out of power --- .../TileEntityArcaneReconstructor.java | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/main/java/am2/blocks/tileentities/TileEntityArcaneReconstructor.java b/src/main/java/am2/blocks/tileentities/TileEntityArcaneReconstructor.java index dbe8d574a..b451ff65c 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityArcaneReconstructor.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityArcaneReconstructor.java @@ -26,8 +26,6 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.Constants; -import java.util.Random; - public class TileEntityArcaneReconstructor extends TileEntityAMPower implements IInventory, ISidedInventory, IKeystoneLockable{ private ItemStack[] inventory; @@ -39,6 +37,7 @@ public class TileEntityArcaneReconstructor extends TileEntityAMPower implements private final AMVector3 middleRingRotation; private final AMVector3 innerRingRotation; private float rotateOffset = 0; + private int deactivationDelayTicks = 0; private EntityLiving dummyEntity; @@ -90,14 +89,22 @@ public void updateEntity(){ isFirstTick = false; } - if (PowerNodeRegistry.For(this.worldObj).checkPower(this, this.getRepairCost()) && repairCounter++ % getRepairRate() == 0){ - if (!queueRepairableItem()){ - if (performRepair()){ + if (PowerNodeRegistry.For(this.worldObj).checkPower(this, this.getRepairCost())) {// has enough power + if ((repairCounter++ % getRepairRate() == 0) && (!queueRepairableItem())) {// has ticked and already has item queued + if (performRepair()){// something to repair if (!worldObj.isRemote){ PowerNodeRegistry.For(this.worldObj).consumePower(this, PowerNodeRegistry.For(worldObj).getHighestPowerType(this), this.getRepairCost()); } } } + deactivationDelayTicks = 0; + } else if (!worldObj.isRemote && active){// out of power, on server and active + if (deactivationDelayTicks++ > 100) {// 5 seconds + deactivationDelayTicks = 0; + this.active = false; + if (!worldObj.isRemote) + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } } if (worldObj.isRemote){ updateRotations(); @@ -138,9 +145,10 @@ public boolean shouldRenderRotateOffset(){ private void updateRotations(){ if (active){ - if (ringOffset < 0.5){ + if (ringOffset < 0.5f){ ringOffset += 0.015f; }else{ + ringOffset = 0.51f; outerRingRotation.add(outerRingRotationSpeeds); middleRingRotation.add(middleRingRotationSpeeds); innerRingRotation.add(innerRingRotationSpeeds); @@ -166,8 +174,10 @@ private void updateRotations(){ innerRingRotation.y = easeCoordinate(innerRingRotation.y, innerRingRotationSpeeds.y); innerRingRotation.z = easeCoordinate(innerRingRotation.z, innerRingRotationSpeeds.z); }else{ - if (ringOffset > 0){ + if (ringOffset > 0f){ ringOffset -= 0.03f; + } else { + ringOffset = 0f; } } } @@ -223,7 +233,14 @@ public AMVector3 getOuterRingRotation(){ } private boolean queueRepairableItem(){ - if (inventory[SLOT_ACTIVE] != null) return false; + if (inventory[SLOT_ACTIVE] != null) { + if (!active) { + this.active = true; + if (!worldObj.isRemote) + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + return false; + } for (int i = 4; i < 10; ++i){ if (itemStackIsValid(inventory[i])){ inventory[SLOT_ACTIVE] = inventory[i].copy(); @@ -258,7 +275,6 @@ private boolean performRepair(){ return true; } - if (inventory[SLOT_ACTIVE].isItemDamaged()){ if (!worldObj.isRemote) inventory[SLOT_ACTIVE].damageItem(-1, getDummyEntity()); @@ -370,6 +386,8 @@ public void readFromNBT(NBTTagCompound nbttagcompound){ inventory[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } + active = nbttagcompound.getBoolean("ArcaneReconstructorActive"); + repairCounter = nbttagcompound.getInteger("ArcaneReconstructorRepairCounter"); } @Override @@ -387,6 +405,8 @@ public void writeToNBT(NBTTagCompound nbttagcompound){ } nbttagcompound.setTag("ArcaneReconstructorInventory", nbttaglist); + nbttagcompound.setBoolean("ArcaneReconstructorActive", active); + nbttagcompound.setInteger("ArcaneReconstructorRepairCounter", repairCounter); } private int numFociOfType(Class type){ From 9260abff491ec7cd5cdcf71daa253f0ec108e7cf Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sat, 28 Nov 2015 14:01:58 +0100 Subject: [PATCH 13/34] Fixed shrink effect transition Slower and smoother vertical transition Minor CPU load improvements --- src/main/java/am2/AMClientEventHandler.java | 2 +- src/main/java/am2/ShrinkHandler.java | 37 +++++++++---------- src/main/java/am2/models/ModelCloaks.java | 4 +- .../playerextensions/ExtendedProperties.java | 7 +--- 4 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/main/java/am2/AMClientEventHandler.java b/src/main/java/am2/AMClientEventHandler.java index 8d9b312e9..ed9d85a6d 100644 --- a/src/main/java/am2/AMClientEventHandler.java +++ b/src/main/java/am2/AMClientEventHandler.java @@ -259,7 +259,7 @@ public void onPlayerRender(RenderPlayerEvent.Pre event){ float shrink = ExtendedProperties.For(event.entityPlayer).getShrinkPct(); if (shrink > 0){ GL11.glPushMatrix(); - GL11.glTranslatef(0, -0.5f, 0); + GL11.glTranslatef(0, 0 - 0.5f * shrink, 0); GL11.glScalef(1 - 0.5f * shrink, 1 - 0.5f * shrink, 1 - 0.5f * shrink); } diff --git a/src/main/java/am2/ShrinkHandler.java b/src/main/java/am2/ShrinkHandler.java index 70db30fe9..389bad9f0 100644 --- a/src/main/java/am2/ShrinkHandler.java +++ b/src/main/java/am2/ShrinkHandler.java @@ -2,24 +2,24 @@ import am2.api.math.AMVector2; import am2.playerextensions.ExtendedProperties; +import am2.spell.SkillManager; +import am2.spell.SkillTreeManager; import am2.utility.EntityUtilities; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.event.entity.living.LivingEvent; -import scala.collection.mutable.HashMap; public class ShrinkHandler{ - private HashMap currentSizes = new HashMap(); - private HashMap sizeModifiers = new HashMap(); - @SubscribeEvent public void onEntityLiving(LivingEvent event){ - ExtendedProperties exProps = null; - if (!(event.entityLiving instanceof EntityPlayer)) return; - EntityLivingBase ent = event.entityLiving; + + if (SkillTreeManager.instance.isSkillDisabled(SkillManager.instance.getSkill("Shrink"))) + return; + + + ExtendedProperties exProps = null; try{ exProps = ExtendedProperties.For(event.entityLiving); @@ -31,30 +31,27 @@ public void onEntityLiving(LivingEvent event){ exProps.originalSize = new AMVector2(event.entityLiving.width, event.entityLiving.height); } - float shrinkPct = 1 - (0.5f * exProps.getShrinkPct()); - - float calculatedSizeW = (float)(exProps.originalSize.x * shrinkPct); - float calculatedSizeH = (float)(exProps.originalSize.y * shrinkPct); - exProps.shrinkTick(); if (exProps.getShrinkPct() > 0f){ if (exProps.shrinkAmount == 0f || //shrink hasn't yet been applied - exProps.getOriginalSize().x * 0.5 != ent.width || //width has changed through other means - exProps.getOriginalSize().y * 0.5 != ent.height){ //height has changed through other means - exProps.setOriginalSize(new AMVector2(ent.width, ent.height)); - EntityUtilities.setSize(ent, ent.width * 0.5f, ent.height * 0.5f); + exProps.getOriginalSize().x * 0.5 != event.entityLiving.width || //width has changed through other means + exProps.getOriginalSize().y * 0.5 != event.entityLiving.height){ //height has changed through other means + exProps.setOriginalSize(new AMVector2(event.entityLiving.width, event.entityLiving.height)); + EntityUtilities.setSize(event.entityLiving, event.entityLiving.width * 0.5f, event.entityLiving.height * 0.5f); exProps.shrinkAmount = 0.5f; } }else{ if (exProps.shrinkAmount != 0f){ - AMVector2 size = ExtendedProperties.For(ent).getOriginalSize(); - EntityUtilities.setSize(ent, (float)(size.x), (float)(size.y)); + AMVector2 size = ExtendedProperties.For(event.entityLiving).getOriginalSize(); + EntityUtilities.setSize(event.entityLiving, (float)(size.x), (float)(size.y)); exProps.shrinkAmount = 0f; if (exProps.getIsFlipped()){ - ent.moveEntity(0, -1, 0); + event.entityLiving.moveEntity(0, -1, 0); } } } + // always update offset + event.entityLiving.yOffset = (float)(exProps.getOriginalSize().y) * 0.8f * (1f - 0.5f * exProps.getShrinkPct()); } } diff --git a/src/main/java/am2/models/ModelCloaks.java b/src/main/java/am2/models/ModelCloaks.java index e8a255772..363258cd4 100644 --- a/src/main/java/am2/models/ModelCloaks.java +++ b/src/main/java/am2/models/ModelCloaks.java @@ -167,8 +167,8 @@ public void render(EntityPlayer player, ModelBiped mainModel, float f5, float pa GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F); copyRotations(mainModel); - if (ExtendedProperties.For(player).getShrinkPct() > 0){ - float pct = ExtendedProperties.For(player).getShrinkPct(); + float pct = ExtendedProperties.For(player).getShrinkPct(); + if (pct > 0){ float amt = 0.5f * pct; GL11.glTranslatef(0, 1 * 1 - pct, 0); GL11.glScalef(1 - amt, 1 - amt, 1 - amt); diff --git a/src/main/java/am2/playerextensions/ExtendedProperties.java b/src/main/java/am2/playerextensions/ExtendedProperties.java index 1a7f050f3..fc58cb54e 100644 --- a/src/main/java/am2/playerextensions/ExtendedProperties.java +++ b/src/main/java/am2/playerextensions/ExtendedProperties.java @@ -1208,9 +1208,6 @@ else if (!flipped && flipRotation > 0) public void shrinkTick(){ - if (SkillTreeManager.instance.isSkillDisabled(SkillManager.instance.getSkill("Shrink"))) - return; - boolean shrunk = getIsShrunk(); if (!entity.worldObj.isRemote && shrunk && !entity.isPotionActive(BuffList.shrink)){ @@ -1223,9 +1220,9 @@ public void shrinkTick(){ prevShrinkPct = shrinkPct; if (shrunk && shrinkPct < 1f){ - shrinkPct += 0.05f; + shrinkPct += 0.002f; }else if (!shrunk && shrinkPct > 0f){ - shrinkPct -= 0.05f; + shrinkPct -= 0.002f; } } From 50fe4889551e9ddd8a242d1b99b07bdb1f58d955 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sat, 28 Nov 2015 16:10:15 +0100 Subject: [PATCH 14/34] Fixed rounding with shink effect --- src/main/java/am2/playerextensions/ExtendedProperties.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/am2/playerextensions/ExtendedProperties.java b/src/main/java/am2/playerextensions/ExtendedProperties.java index fc58cb54e..7cf216b63 100644 --- a/src/main/java/am2/playerextensions/ExtendedProperties.java +++ b/src/main/java/am2/playerextensions/ExtendedProperties.java @@ -1220,9 +1220,9 @@ public void shrinkTick(){ prevShrinkPct = shrinkPct; if (shrunk && shrinkPct < 1f){ - shrinkPct += 0.002f; + shrinkPct = Math.min(1f, shrinkPct + 0.002f); }else if (!shrunk && shrinkPct > 0f){ - shrinkPct -= 0.002f; + shrinkPct = Math.max(0f, shrinkPct - 0.002f); } } From d9aec672787238369146b39dd34573b4e9c773a5 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sat, 28 Nov 2015 16:10:46 +0100 Subject: [PATCH 15/34] Code cleanup --- src/main/java/am2/buffs/BuffEffect.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/am2/buffs/BuffEffect.java b/src/main/java/am2/buffs/BuffEffect.java index e78e13201..67fc9920b 100644 --- a/src/main/java/am2/buffs/BuffEffect.java +++ b/src/main/java/am2/buffs/BuffEffect.java @@ -40,9 +40,11 @@ private void effectEnding(EntityLivingBase entityliving){ } //Effect that is performed on intermediate ticks + @Override public void performEffect(EntityLivingBase entityliving){ } + @Override public void combine(PotionEffect potioneffect){ //don't combine "potion effects" with other buff effects if (!(potioneffect instanceof BuffEffect)){ @@ -55,6 +57,7 @@ public void combine(PotionEffect potioneffect){ } } + @Override public boolean onUpdate(EntityLivingBase entityliving){ //check for if we are for the first time applying the effect if (InitialApplication){ @@ -87,6 +90,7 @@ public boolean isReady(int i, int j){ protected abstract String spellBuffName(); + @Override public String getEffectName(){ return String.format("Spell: %s", spellBuffName()); } From 9892d89ebc6c024da8cee653d77712d0053e27e9 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sat, 28 Nov 2015 16:13:57 +0100 Subject: [PATCH 16/34] Fixed network lag Changed to only apply/remove modifiers when necessary Entities are still updating every tick but bandwitch usage is much lower (~770 -> ~140 bytes per entities per tick) --- .../java/am2/buffs/BuffStatModifiers.java | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/src/main/java/am2/buffs/BuffStatModifiers.java b/src/main/java/am2/buffs/BuffStatModifiers.java index a8823d332..d4c43724b 100644 --- a/src/main/java/am2/buffs/BuffStatModifiers.java +++ b/src/main/java/am2/buffs/BuffStatModifiers.java @@ -17,15 +17,11 @@ public void applyStatModifiersBasedOnBuffs(EntityLivingBase entity){ //entangled applyOrRemoveModifiersForBuff(entity, BuffList.entangled.id, new KeyValuePair(SharedMonsterAttributes.movementSpeed, entangled)); //frost slow - applyOrRemoveModifiersForBuff(entity, BuffList.frostSlowed.id, 0, new KeyValuePair(SharedMonsterAttributes.movementSpeed, frostSlow_Diminished)); - applyOrRemoveModifiersForBuff(entity, BuffList.frostSlowed.id, 1, new KeyValuePair(SharedMonsterAttributes.movementSpeed, frostSlow_Normal)); - applyOrRemoveModifiersForBuff(entity, BuffList.frostSlowed.id, 2, new KeyValuePair(SharedMonsterAttributes.movementSpeed, frostSlow_Augmented)); + applyOrRemoveScalingModifiersForBuff(entity, BuffList.frostSlowed.id, SharedMonsterAttributes.movementSpeed, frostSlow_Diminished, frostSlow_Normal, frostSlow_Augmented); //fury applyOrRemoveModifiersForBuff(entity, BuffList.fury.id, new KeyValuePair(SharedMonsterAttributes.movementSpeed, furyMoveMod), new KeyValuePair(SharedMonsterAttributes.attackDamage, furyDmgMod)); //haste - applyOrRemoveModifiersForBuff(entity, BuffList.haste.id, 0, new KeyValuePair(SharedMonsterAttributes.movementSpeed, hasteSpeedBoost_Diminished)); - applyOrRemoveModifiersForBuff(entity, BuffList.haste.id, 1, new KeyValuePair(SharedMonsterAttributes.movementSpeed, hasteSpeedBoost_Normal)); - applyOrRemoveModifiersForBuff(entity, BuffList.haste.id, 2, new KeyValuePair(SharedMonsterAttributes.movementSpeed, hasteSpeedBoost_Augmented)); + applyOrRemoveScalingModifiersForBuff(entity, BuffList.haste.id, SharedMonsterAttributes.movementSpeed, hasteSpeedBoost_Diminished, hasteSpeedBoost_Normal, hasteSpeedBoost_Augmented); } private void applyOrRemoveModifiersForBuff(EntityLivingBase entity, int buffID, KeyValuePair... modifiers){ @@ -36,12 +32,25 @@ private void applyOrRemoveModifiersForBuff(EntityLivingBase entity, int buffID, } } - private void applyOrRemoveModifiersForBuff(EntityLivingBase entity, int buffID, int magnitude, KeyValuePair... modifiers){ - if (entity.isPotionActive(buffID)){ - if (entity.getActivePotionEffect(Potion.potionTypes[buffID]).getAmplifier() == magnitude) - applyAllModifiers(entity, modifiers); + private void applyOrRemoveScalingModifiersForBuff(EntityLivingBase entity, int potionID, IAttribute attribute, AttributeModifier... modifiers){ + IAttributeInstance inst = entity.getEntityAttribute(attribute); + if (inst == null) { + return; + } + AttributeModifier currentModifier = inst.getModifier(modifiers[0].getID()); + if (entity.isPotionActive(potionID)){ + int magnitude = entity.getActivePotionEffect(Potion.potionTypes[potionID]).getAmplifier(); + AttributeModifier modifier = modifiers[Math.min(magnitude, modifiers.length - 1)]; + if (currentModifier != modifier) { + if (currentModifier != null) { + inst.removeModifier(currentModifier); + } + inst.applyModifier(modifier); + } }else{ - clearAllModifiers(entity, modifiers); + if (currentModifier != null) { + inst.removeModifier(currentModifier); + } } } @@ -50,8 +59,13 @@ private void applyAllModifiers(EntityLivingBase entity, KeyValuePair Date: Sun, 29 Nov 2015 00:44:50 +0100 Subject: [PATCH 17/34] Refactored shrink handling Fixed movement glitches due to multiple part of the code chanding the player properties While a few display glitches remain, the overall is more fluid/stable now, --- src/main/java/am2/AMEventHandler.java | 2 - src/main/java/am2/ShrinkHandler.java | 51 +++++++++++++++---- .../playerextensions/ExtendedProperties.java | 42 ++------------- 3 files changed, 45 insertions(+), 50 deletions(-) diff --git a/src/main/java/am2/AMEventHandler.java b/src/main/java/am2/AMEventHandler.java index f3043d1cc..2b9514e33 100644 --- a/src/main/java/am2/AMEventHandler.java +++ b/src/main/java/am2/AMEventHandler.java @@ -332,8 +332,6 @@ public void onEntityLiving(LivingUpdateEvent event){ //archmage armor effects & infusion if (ent instanceof EntityPlayer){ - extendedProperties.overrideEyeHeight(); - if (ent.worldObj.isRemote){ int divisor = ExtendedProperties.For(ent).getAuraDelay() > 0 ? ExtendedProperties.For(ent).getAuraDelay() : 1; if (ent.ticksExisted % divisor == 0) diff --git a/src/main/java/am2/ShrinkHandler.java b/src/main/java/am2/ShrinkHandler.java index 389bad9f0..446a79f2a 100644 --- a/src/main/java/am2/ShrinkHandler.java +++ b/src/main/java/am2/ShrinkHandler.java @@ -1,6 +1,7 @@ package am2; import am2.api.math.AMVector2; +import am2.buffs.BuffList; import am2.playerextensions.ExtendedProperties; import am2.spell.SkillManager; import am2.spell.SkillTreeManager; @@ -15,6 +16,8 @@ public class ShrinkHandler{ public void onEntityLiving(LivingEvent event){ if (!(event.entityLiving instanceof EntityPlayer)) return; + EntityPlayer player = (EntityPlayer) event.entityLiving; + if (SkillTreeManager.instance.isSkillDisabled(SkillManager.instance.getSkill("Shrink"))) return; @@ -22,36 +25,62 @@ public void onEntityLiving(LivingEvent event){ ExtendedProperties exProps = null; try{ - exProps = ExtendedProperties.For(event.entityLiving); + exProps = ExtendedProperties.For(player); }catch (Throwable t){ return; } if (exProps.originalSize == null){ - exProps.originalSize = new AMVector2(event.entityLiving.width, event.entityLiving.height); + exProps.originalSize = new AMVector2(player.width, player.height); } - exProps.shrinkTick(); + boolean shrunk = exProps.getIsShrunk(); + + if (!player.worldObj.isRemote && shrunk && !player.isPotionActive(BuffList.shrink)){ + exProps.setIsShrunk(false); + shrunk = false; + player.yOffset = (float)exProps.getOriginalSize().y * 0.9f; + }else if (!player.worldObj.isRemote && !shrunk && player.isPotionActive(BuffList.shrink)){ + exProps.setIsShrunk(true); + shrunk = true; + player.yOffset = 0.0F; + } + + float shrinkPct = exProps.getShrinkPct(); + if (shrunk && shrinkPct < 1f){ + shrinkPct = Math.min(1f, shrinkPct + 0.005f); + }else if (!shrunk && shrinkPct > 0f){ + shrinkPct = Math.max(0f, shrinkPct - 0.005f); + } + exProps.setShrinkPct(shrinkPct); if (exProps.getShrinkPct() > 0f){ if (exProps.shrinkAmount == 0f || //shrink hasn't yet been applied - exProps.getOriginalSize().x * 0.5 != event.entityLiving.width || //width has changed through other means - exProps.getOriginalSize().y * 0.5 != event.entityLiving.height){ //height has changed through other means - exProps.setOriginalSize(new AMVector2(event.entityLiving.width, event.entityLiving.height)); - EntityUtilities.setSize(event.entityLiving, event.entityLiving.width * 0.5f, event.entityLiving.height * 0.5f); + exProps.getOriginalSize().x * 0.5 != player.width || //width has changed through other means + exProps.getOriginalSize().y * 0.5 != player.height){ //height has changed through other means + exProps.setOriginalSize(new AMVector2(player.width, player.height)); exProps.shrinkAmount = 0.5f; + EntityUtilities.setSize(player, player.width * exProps.shrinkAmount, player.height * exProps.shrinkAmount); + player.eyeHeight = player.getDefaultEyeHeight() * exProps.shrinkAmount; + player.yOffset = 0.0f; } }else{ if (exProps.shrinkAmount != 0f){ - AMVector2 size = ExtendedProperties.For(event.entityLiving).getOriginalSize(); - EntityUtilities.setSize(event.entityLiving, (float)(size.x), (float)(size.y)); + AMVector2 size = ExtendedProperties.For(player).getOriginalSize(); + EntityUtilities.setSize(player, (float)(size.x), (float)(size.y)); exProps.shrinkAmount = 0f; + player.eyeHeight = player.getDefaultEyeHeight(); + player.yOffset = 0.0f; if (exProps.getIsFlipped()){ event.entityLiving.moveEntity(0, -1, 0); } } } - // always update offset - event.entityLiving.yOffset = (float)(exProps.getOriginalSize().y) * 0.8f * (1f - 0.5f * exProps.getShrinkPct()); + + // update Y offset + if (player.worldObj.isRemote && exProps.getPrevShrinkPct() != exProps.getShrinkPct()){ + // Vanilla player is 1.8f height with 1.62f yOffset => 0.9f + player.yOffset = (float)exProps.getOriginalSize().y * 0.9f * (1f - 0.5f * exProps.getShrinkPct()); + } } } diff --git a/src/main/java/am2/playerextensions/ExtendedProperties.java b/src/main/java/am2/playerextensions/ExtendedProperties.java index 7cf216b63..19234ffc0 100644 --- a/src/main/java/am2/playerextensions/ExtendedProperties.java +++ b/src/main/java/am2/playerextensions/ExtendedProperties.java @@ -414,6 +414,11 @@ public float getPrevShrinkPct(){ return this.prevShrinkPct; } + public void setShrinkPct(float pct){ + this.prevShrinkPct = this.shrinkPct; + this.shrinkPct = pct; + } + public boolean shouldReverseInput(){ return getFlipRotation() > 0 || this.entity.isPotionActive(BuffList.scrambleSynapses.id); } @@ -422,23 +427,6 @@ public AMVector2 getOriginalSize(){ return this.originalSize; } - public void overrideEyeHeight(){ - if (SkillTreeManager.instance.isSkillDisabled(SkillManager.instance.getSkill("Shrink"))) - return; - - if (entity instanceof EntityPlayer){ - float baseEyeHeight = ((EntityPlayer)entity).getDefaultEyeHeight(); - float baseYOffset = entity.worldObj.isRemote ? (entity == AMCore.proxy.getLocalPlayer() ? 1.62f : 0) : 0; - if (entity.isPotionActive(BuffList.shrink)){ - ((EntityPlayer)entity).eyeHeight = baseEyeHeight / 2; - entity.yOffset = baseYOffset / 2; - }else{ - ((EntityPlayer)entity).eyeHeight = baseEyeHeight; - entity.yOffset = baseYOffset; - } - } - } - public boolean getCanHeal(){ return healCooldown <= 0; } @@ -1206,26 +1194,6 @@ else if (!flipped && flipRotation > 0) flipRotation -= 15; } - public void shrinkTick(){ - - boolean shrunk = getIsShrunk(); - - if (!entity.worldObj.isRemote && shrunk && !entity.isPotionActive(BuffList.shrink)){ - setIsShrunk(false); - return; - }else if (!entity.worldObj.isRemote && !shrunk && entity.isPotionActive(BuffList.shrink)){ - setIsShrunk(true); - return; - } - - prevShrinkPct = shrinkPct; - if (shrunk && shrinkPct < 1f){ - shrinkPct = Math.min(1f, shrinkPct + 0.002f); - }else if (!shrunk && shrinkPct > 0f){ - shrinkPct = Math.max(0f, shrinkPct - 0.002f); - } - } - public void cleanupManaLinks(){ Iterator it = this.manaLinks.iterator(); while (it.hasNext()){ From 267d7d596aa25e65d29d5187126d80ba3a8f38bd Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sun, 29 Nov 2015 01:40:43 +0100 Subject: [PATCH 18/34] Code cleanup --- src/main/java/am2/blocks/BlocksCommonProxy.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/am2/blocks/BlocksCommonProxy.java b/src/main/java/am2/blocks/BlocksCommonProxy.java index 999c3570c..66ee3071e 100644 --- a/src/main/java/am2/blocks/BlocksCommonProxy.java +++ b/src/main/java/am2/blocks/BlocksCommonProxy.java @@ -621,11 +621,11 @@ public void InitRecipes(){ }); //storage blocks - createStorageBlockRecipe(new ItemStack(AMOres, 1, 5), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_MOONSTONE)); - createStorageBlockRecipe(new ItemStack(AMOres, 1, 6), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_VINTEUMDUST)); - createStorageBlockRecipe(new ItemStack(AMOres, 1, 7), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_BLUETOPAZ)); - createStorageBlockRecipe(new ItemStack(AMOres, 1, 8), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_SUNSTONE)); - createStorageBlockRecipe(new ItemStack(AMOres, 1, 9), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_CHIMERITE)); + createStorageBlockRecipe(new ItemStack(AMOres, 1, AMOres.META_MOONSTONE_BLOCK), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_MOONSTONE)); + createStorageBlockRecipe(new ItemStack(AMOres, 1, AMOres.META_VINTEUM_BLOCK), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_VINTEUMDUST)); + createStorageBlockRecipe(new ItemStack(AMOres, 1, AMOres.META_BLUE_TOPAZ_BLOCK), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_BLUETOPAZ)); + createStorageBlockRecipe(new ItemStack(AMOres, 1, AMOres.META_SUNSTONE_BLOCK), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_SUNSTONE)); + createStorageBlockRecipe(new ItemStack(AMOres, 1, AMOres.META_CHIMERITE_BLOCK), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_CHIMERITE)); //furnace recipes GameRegistry.addSmelting(new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_ARCANECOMPOUND), new ItemStack(ItemsCommonProxy.itemOre, 2, ItemsCommonProxy.itemOre.META_ARCANEASH), 0); From f98b061bd854c0528b064b45754f768f3e697fc3 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sun, 6 Dec 2015 02:30:45 +0100 Subject: [PATCH 19/34] Improved CPU usage a bit Code cleanup --- src/main/java/am2/AMEventHandler.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/am2/AMEventHandler.java b/src/main/java/am2/AMEventHandler.java index 2b9514e33..42cae4739 100644 --- a/src/main/java/am2/AMEventHandler.java +++ b/src/main/java/am2/AMEventHandler.java @@ -14,7 +14,6 @@ import am2.buffs.BuffList; import am2.buffs.BuffStatModifiers; import am2.damage.DamageSources; -import am2.enchantments.EnchantmentSoulbound; import am2.entities.EntityFlicker; import am2.items.ItemsCommonProxy; import am2.network.AMNetHandler; @@ -140,7 +139,6 @@ public void onEntityConstructing(EntityConstructing event){ @SubscribeEvent(priority = EventPriority.HIGHEST) public void onEntityDeath(LivingDeathEvent event){ - String s = EnchantmentSoulbound.class.getName(); EntityLivingBase soonToBeDead = event.entityLiving; if (soonToBeDead.isPotionActive(BuffList.temporalAnchor.id)){ event.setCanceled(true); @@ -241,6 +239,8 @@ public void onEntityJump(LivingJumpEvent event){ xVelocity = velocityTarget.motionX * 1.75 * Math.abs(vec.xCoord); zVelocity = velocityTarget.motionZ * 1.75 * Math.abs(vec.zCoord); break; + default: + break; } float maxHorizontalVelocity = 1.45f; @@ -320,8 +320,6 @@ public void onEntityLiving(LivingUpdateEvent event){ World world = ent.worldObj; - boolean isRemote = world.isRemote; - BuffStatModifiers.instance.applyStatModifiersBasedOnBuffs(ent); ExtendedProperties extendedProperties; @@ -473,6 +471,8 @@ public void onEntityLiving(LivingUpdateEvent event){ case BuffPowerLevel.High: extendedProperties.setFallProtection(45); break; + default: + break; } } @@ -484,7 +484,10 @@ public void onEntityLiving(LivingUpdateEvent event){ //slowfall/shrink buff - if (event.entityLiving.isPotionActive(BuffList.slowfall) || event.entityLiving.isPotionActive(BuffList.shrink) || (!ent.isSneaking() && ent instanceof EntityPlayer && AffinityData.For(ent).getAffinityDepth(Affinity.NATURE) == 1.0f)){ + // (isSneaking calls DataWatcher which are slow, so we test it late) + if ( event.entityLiving.isPotionActive(BuffList.slowfall) + || event.entityLiving.isPotionActive(BuffList.shrink) + || (ent instanceof EntityPlayer && AffinityData.For(ent).getAffinityDepth(Affinity.NATURE) == 1.0f && !ent.isSneaking())){ if (!event.entityLiving.onGround && event.entityLiving.motionY < 0.0D){ event.entityLiving.motionY *= 0.79999999999999998D; } @@ -668,7 +671,7 @@ public void onManaCost(ManaCostEvent event){ @SubscribeEvent public void onPlayerPickupItem(EntityItemPickupEvent event){ - if (!(event.entityPlayer instanceof EntityPlayer)) + if (event.entityPlayer == null) return; if (!event.entityPlayer.worldObj.isRemote && ExtendedProperties.For(event.entityPlayer).getMagicLevel() <= 0 && event.item.getEntityItem().getItem() == ItemsCommonProxy.arcaneCompendium){ From 00a71eaf2840b643aae975bd2807555d57c1b019 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sun, 6 Dec 2015 03:03:09 +0100 Subject: [PATCH 20/34] Fixed flowers compatibility with modded world generation Desert nova can now spawn on all sands, not only Vanilla. Tarma root can now spawn on all stones and cobblestones, not only Vanilla. --- src/main/java/am2/blocks/BlockDesertNova.java | 21 +++++++++++++++- src/main/java/am2/blocks/BlockTarmaRoot.java | 24 ++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/main/java/am2/blocks/BlockDesertNova.java b/src/main/java/am2/blocks/BlockDesertNova.java index 5a8ce9e56..63c4c80e8 100644 --- a/src/main/java/am2/blocks/BlockDesertNova.java +++ b/src/main/java/am2/blocks/BlockDesertNova.java @@ -8,14 +8,20 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.EnumPlantType; +import net.minecraftforge.oredict.OreDictionary; +import java.util.Collection; +import java.util.HashSet; import java.util.Random; public class BlockDesertNova extends AMFlower{ + static HashSet blockSands = null; + protected BlockDesertNova(){ super(); } @@ -32,7 +38,20 @@ public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z){ @Override protected boolean canPlaceBlockOn(Block block){ - return block == Blocks.sand; + if (block == Blocks.sand){ + return true; + } + if (blockSands == null){// sand is defined by Forge, hence only first call will be 'true' + Collection itemStackSands = OreDictionary.getOres("sand", false); + blockSands = new HashSet(itemStackSands.size()); + for (ItemStack itemStack : itemStackSands){ + Block oreBlock = Block.getBlockFromItem(itemStack.getItem()); + if (oreBlock != Blocks.air){ + blockSands.add(oreBlock); + } + } + } + return blockSands != null && blockSands.contains(block); } @Override diff --git a/src/main/java/am2/blocks/BlockTarmaRoot.java b/src/main/java/am2/blocks/BlockTarmaRoot.java index cff9d5dd4..f00019b85 100644 --- a/src/main/java/am2/blocks/BlockTarmaRoot.java +++ b/src/main/java/am2/blocks/BlockTarmaRoot.java @@ -1,13 +1,19 @@ package am2.blocks; +import java.util.HashSet; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.EnumPlantType; +import net.minecraftforge.oredict.OreDictionary; public class BlockTarmaRoot extends AMFlower{ + static HashSet blockStones = null; + protected BlockTarmaRoot(){ super(); } @@ -25,7 +31,23 @@ public boolean canBlockStay(World worldIn, int x, int y, int z){ @Override protected boolean canPlaceBlockOn(Block block){ - return block == Blocks.stone || block == Blocks.cobblestone; + if (block == Blocks.stone || block == Blocks.cobblestone){ + return true; + } + if (blockStones == null){// stone and cobblestone are defined by Forge, hence only first call will be 'true' + HashSet itemStackStones = new HashSet(); + itemStackStones.addAll(OreDictionary.getOres("stone", false)); + itemStackStones.addAll(OreDictionary.getOres("stoneCobble", false)); + itemStackStones.addAll(OreDictionary.getOres("cobblestone", false)); + blockStones = new HashSet(itemStackStones.size()); + for (ItemStack itemStack : itemStackStones){ + Block oreBlock = Block.getBlockFromItem(itemStack.getItem()); + if (oreBlock != Blocks.air){ + blockStones.add(oreBlock); + } + } + } + return blockStones != null && blockStones.contains(block); } //EoD: Tarmas should only grow in dark places From 738be97963420fe58767b057ea99b6d4fec8afeb Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sun, 6 Dec 2015 13:18:32 +0100 Subject: [PATCH 21/34] Added missing textures and name for creative spells Quick and dirty textures so we don't have those purple/black missing ones --- .../resources/assets/arsmagica2/lang/en_US.lang | 3 +++ .../items/spells/components/Nauseate.png | Bin 0 -> 5091 bytes .../items/spells/components/ScrambleSynapses.png | Bin 0 -> 5403 bytes 3 files changed, 3 insertions(+) create mode 100644 src/main/resources/assets/arsmagica2/textures/items/spells/components/Nauseate.png create mode 100644 src/main/resources/assets/arsmagica2/textures/items/spells/components/ScrambleSynapses.png diff --git a/src/main/resources/assets/arsmagica2/lang/en_US.lang b/src/main/resources/assets/arsmagica2/lang/en_US.lang index 17b1fbaca..0baf0e29d 100644 --- a/src/main/resources/assets/arsmagica2/lang/en_US.lang +++ b/src/main/resources/assets/arsmagica2/lang/en_US.lang @@ -400,6 +400,9 @@ am2.spell.manaregenii=Mana Regen II am2.spell.manaregeniii=Mana Regen III am2.spell.spellmotion=Spell Motion +am2.spell.nauseate=Nauseate +am2.spell.scramblesynapses=Scramble synapses + #tooltips am2.tooltip.air_sled=§3Fly through the air with the greatest of ease...§f am2.tooltip.approError=Something went wrong restoring the block. This spell was likely a spell from an older version. The stored block has been cleared to prevent a crash, and the spell should work moving forward. Sorry! diff --git a/src/main/resources/assets/arsmagica2/textures/items/spells/components/Nauseate.png b/src/main/resources/assets/arsmagica2/textures/items/spells/components/Nauseate.png new file mode 100644 index 0000000000000000000000000000000000000000..2d6b5e83558b95947ba2918e6e29fe1b037d642b GIT binary patch literal 5091 zcmV<96CCV`P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGf5&!@T5&_cPe*6Fc00(qQO+^RY1s)a& zG8^nah5!Hn7<5HgbW?9;ba!ELWdLwtX>N2bZe?^JG%heMHvEiZ-v9s;K}keGRCr$P zT4!)nSC;OeR;!Z|LOCZy6iI-PFd%{l5tMVz8ReW%1SEt60s$f$Y>aKNXKZF1Sce&p zcf9u4Ymaf*UGGj!P1Vew-JP1FRj~VdHkUcKqAQ1I{qDxeQ&+os}lOq_!A-WhHj49 z;rTHK>kTfbazxxd?)dQdk1Fy;ZXMU)#R;AD#*mnpC^RWK2`R}bNKH*eT6#J%GSZQi zk%jE+Y~*C;A}===Sy`DV$S*`;VG)Xpi&0Wig3_{5l$Tf7tjV0fhOizZ{ZT~Tz@xw? z2=GY~_>>f+5%~19G^A%_%z@8BPEHPTbMugwmyd#i0(g3Q3SGZ`1IkKEQC41#ipmO9 zRaM%oeUZrYYQLS$80ilx@{6B6N`yCNZ@m#DS$m$qr>3SMEsZ>%o`KBFInU>06L|7| zem)8bd|_ds@Vuv+9vV9p)M~XbMqFGRs;g>HTT^TE4z4D5PcE?;BmF@{e&N*t&U;&8 zN=!_6WZ0)u*k@9hXJ=W$KA*s|=Oyq(D4h%YP=5pbJazE(azc1m5Tc`_MI;Y+fvYvnD6afls5b7vM9Il}Y-DuxIc^9ur;{ zo=-+{O0obi!k#@(;Mw!J3_dRx1q{BBz!ynj&xBV-p06mYKt)9*DyypCY_tiR$WV)KJa`dK(Zx8o%8S2jc>< zZKD?ge2fSS3qwOggUuc|6<)vKYcoc=AR;gL;3Mu4xYtD~H+hsP2fg8fWL+8c_z#0YFywG;vVzKD#B zL}zEG&0g-FT7s7*oNdNPzn91h-I;KsCd78}B=Wj7;iYiS6ZrJZbcA>-;qI(}UaNqk zUJ12I0j<3fMx7EGwE}jeK1=Nhe3|fkbtQqXsTOQsS9e$tUVTG78XB8m&}-o5WkN-E zB!wQKcDrp86*9hL|)+eV=lNg>T129sPjn)R)i*^nSO)WAI5y$uf9*jS?;}wp{1o6t*x!Jt`aR}Q8?KXOB#b*N{7AM zBd|3(3VnTj7#JL|+2ez^;_%^5H(QU*Tg1faCM9NCEnS!JJS&4|wogr=n(ZJwsj*YQ z&qIxj-8vM-+o3AK4sAJ(7_IWbWK$51)%c>n)DzuB-e}4VKvJBiD0yr=C9Q3sbZMZl zZ=|qi&zr%wx3yE0*dcxgtGebKt*}DtL`y#MCb{*Q=J1{snjN##7d7t0ByASWZ zxIum{MJc0fv;3AJek)TL_BlBLB!nG41b z`(mO#0G$P%$d7kL;X!wlCHtZxH2`hJAt*}l#)=@FND1bQW&+Qpj={IJx1pn>U8KOO zWlJau*5Y*kHk=*YjfUbV?2HM;&Ye36{0K%zN9BEfet!>MyBZ-slg?Yj#EYE z3o+p(6Wc%i^wYFqrO0je;O;H1C{139mRwh~<{HqNWrvPD2lSV?lGi;@mEwlz)p~fj zX~Y~~cP-Y0oA8rZH{`^7V$T*Q5kV^A1`k&?fo~)5?E-v9S0|iIT6nnWP?<$M(7p-h z2DhWHZWFdedBfYogptt^96f3=z=yAG$DQ*b@-ykYMNGWX zVp)&@hjzN7I>Q&O1>Wc`rhL!Wqa()-%~?9sXSg6`rxO9U6Zy_-Fi7?`|7Fey@pZtK z)kY#uwMYdX_xCao_zrYXsq60U65luK?a)xP0>@f5V5)ly#ydA-$7V0+b@pg!Zo%TV2fp9zwmN#`wMB7?s%U^#S1r@C|)jYc>-YH)CeI~wzX&{YzQ{&IiH? z)}bNI9@%@e*t9}R9;d?%0jQ!*JQAxI^QM0 z_w@9L?>U?7k&_UDlikrc-M1B^E$dK_90ZLdtaO>0p7~q)!YJP?+ zC6K`<97=$*lL;$B49Gv^L*PR(P!)>dDt`)lXH+NIV^5SC0aOCH9P;J`ccI3sJH7y2v1Fj7NC zDEC2Qh7q}Y)#O15ID@GY9UgszCP!w3YY~hd3iFkWP=jUN~lz0Qikr#@;m{aJm23hf#Wg$L3Ui_OqcQ`u$eHEb?tPDU)wlfO$*;D9CWM>91wYPN= zI2yO7@Lv|7M*40eGWIwjcAb&HOT7jIW$*X)_M)%94@Zs+h%x?b&sJ9qH?F{B&sq#M zgrTX>6Z^I~iSI{5L|}4qQhbl~xydkG9QKx|&KQcDEz!DjdF-EeZ`v$_eD zX?|pYU}Ar7)T9`Ywo@(gn>TItd|mBfxH{R%;ce0@;I%}B*tI(B*kBai=g)Y3t_pnw zp2Pmgz!70IRvs@(bjDD9AQ>SHM`{Df0N!*`TmpX|JzSg}F?DK6-shDOf1K^HIF5AQ zA|^gNiIsZxf= z_EAy(Q|Cwd&lQ3ri9a(CVOl(YM0l3LGm%CFDp5-0+FIm<9_lRn$p9@Sfyhtt$I5VL zO3Td{8L@PNvjg5Z)!`yPlg?YjM2>)Gj#wgqud(&hTA!s1GI+k+ba!_bVZAPb znx0}0R3_`_;G;mOFP#Y}Tn~$b&0(pxZ)${&+GPgBz(R=pB7(HSyXJM-5bSyWoX-_( z6i;fNc5N}DCW|y(g@XN*1_$Z9kmrh~B7fB71!DawCzy;5SiXEY&YZOv;M&m;%=9e) z2e9`qcRR@oNjEvg@b~u@EpW^_J?e@4%99+B8mGkCFbQNmA8EzGMmo~+!A3Q=MxeI_ zyEZ!_kWPeb7&B*>-@yh557Z(*(G9&d-sr0)zBMZ<9v-f8^jPgPZzO1Z-Tt zN-*`N)efl6bfuDL!lCWtO_Nl%B+nD@Ha^mJNWDF^w?;jCPJt!P8f;i;z=5Z?QDB zl%rkU-Ng32qQf(<$1O3p%>iBtY+Rv0{5E?!T~dRz-wlVUydG(cKz&I#(hvG!RX882*9kJw%+b=*fV0rHys*Pv5CN9n`H zb91p1r$qivfUh2&OQmzd^qFa#HHSUr{Dli-fQP`d{_@3xc>hj<_1L^co_w*>B-DD0 zFEF{z7ZnvDBqW$fOobpH1=fTqscx$TnXzX(JEXAZI&Tera9|L_LqixD9ub_OrAW|H zbHo*Zfiidptz>{;e?3l}J}v6J3|@pifuEhl#fQLu`|C1%{Z26++%K>m|C>Z!;A*c6 zZjE?ZFDTvKQmHE{E`pnz8{A#(s4-Gv6Y1(u=_u?+M`APh{<+?MfWQw4@WU7x9mUaO zqv9ktc6=P+0V+(Kn84)8lbD>E#Hp!MIDLA0&hzH5H|IQg{-Q1T|Ng2S|M{R5fBMAs zCp6N(S>#1tJno0rXKa6r6t}lj=lQ1CWHO1IULK^Rd{$A*OHn|n;Nz|o;0LI^9UL6Q z;LtFJscq#uJU+qkP0sPL<2W%sj){pAI7#5A=wKs(H+!CR=9~ZZl5$y+vN^m)ADpqubl87Z*)V8`XKP^O{N6GWY$n#?uA3uQ;!t_@fF1Wb3zW@1dOk>z7sd!v|UT;`RMD(mPhN<{SFe62G{3k0-yiBp8}UD1+y2K%(kDjbP5tiWZTS4< z7<_zt1Kz*B9QS7f@b+vVK6qvsetSC-U%avj-`tDASNFC`-?_OO|8RAg&|lw*#HX*s z;LA65;hXzUw-VtyBtjE zu?nBx-9X^C;@{ugj(>aeDg5&*oAFOCkP)6+Bfx)rcN2bhZyO%G9w+qEpKZfeZ|=c= zyl-=|V|`-f;f+2Hed6U&n_ehglto#TMOlPx#1ZP1_K>z@;j|==^1poj532;bRa{vGf5&!@T5&_cPe*6Fc00(qQO+^RY1s)a& zG8^nah5!Hn7<5HgbW?9;ba!ELWdLwtX>N2bZe?^JG%heMHvEiZ-v9s-R|Qc}L0Oa?L{Jt1QAFcH(5Nwqi5fd5 zY2$Pz>12|QS!O0Pefsn{-T%x?pPu=5&TsB}1z%N}%pY_xvCrY2a}RuvdhffxyWdxc z)@hyAX`R+-oz|T2g81)(eoXMSQRL9h02z|u)WywbY?^Ic+`J0`+hy9gIL#JJd{ zjmzB|aJ5e#*9KI4rBA{?f4N5&S9(nQ89fqp1u%XoNf7XIk2YQ%Ho&bh6D$s? zl)#vQXME|zGRS@vt1EzkUQq&5)@+-G0vNwkBnWo7SB%BsA6V=s^L(ck=jYa63K9gm zI-rABPwJ@)xTefJVrkg;`So9v1VI*ub#Zf4UtKVyr>Aqy$jm@iW)`xuvyq*XgA7{B zOiDvedKL<^@=;t=gyP~NloXbrw4@9b6&0wgtVC6H6>4f~HO^!?fhj_LjrbQKL4Y3v zpT@ywD8XlCA&0={68Pkl6m0SGh5tr(gvvJ~aZ@1VX4dd>^F*{F2vNR4ND7ZbN$MVy zm6xNot`_z6bsA@%r)0WtTt{P#_-7^I#n%QY;ho%|E(o`;2K)Bz(|8A~ zCb!4THP(oK77|{#(9PmrGcl#7r~Sa~b8>SLvppIPwl=WP*TyzGDH{Ck&>Q7~_AqPRiWzp%VtEfg}L!-vK?wm2l(?u_hHR2aa!iz3+ zig59S#)~=dw6rwt0UUe|xjlgo2?>U+g()13w6W7sisRvO%qP3!QmQ)^Qd}^XB*#pG zEv9zJF`eLo3(4M?O!P%Z_+~T(Dp0k>ANf8JD2dBJQ+wF*+}`7f zy9K^@t0(|(mjvTMStK4-Y{xsLvADS>7N--!(G=u|G&c_v1n$7W(!Cn*e)eV%K3P&| ztP!s%2?w)gg*7zlYiSu2^J&WoZ`tj03H+Wtd*J1`5h2z(DD~1K@CF!*F~n57G3Iw! z;Ci|ock(<4a3DUc+m4U+CE$bFc)V8?hj%Mt@VF|T)|2tLHWhOz;VAZUg13bQVm1e( zuCy9rkxC903ir>+HRK{*6A})*IU=LZ%uxLWg5@(;vVE2^;pOG-fvvSQ0<4YD8e)O* zcymm|>*G|k7KS237~igo`6Of9%5laU1%9|!5{5U6BC(JbgoV@~EMf3IdZ+#WZ_YojuaHR7K{!a=u2EvO06JUoM}uAcC+ zSj-dn+&of1ULIUbjZnAM4%f0hv6SnGOS_FR8LN$vND+p@#pn;$#ZZ(COd#8qMPj2|(^EX2^)`(Y4eB*_72`+a2u)|~EGcq#OVm^nveO`VZ zRf1Gr?!3+Qahu%xtxC@3gEQbGcZbhWV6QXh*so&??(PwEx8 zSL}wdIBUeq^&!<2Lswf1Ru<+cFDpl3VFC6xHR8a5CLBE2jOLbR96Hp3!-o%}^++ok z_U)yH$q+V%dQ?iSQS0l>LuL~t#ir7F^z`(hudh##^Sk$x@WIUh;hA{V#5bO6)yG_$ zfpCzryw9778K@WL188(C7L7N z-W0L+cF6RPLr3#b3=9kia(?+}2i{un6rPD!O?>0|qlTDomkI~5gqO+N+hy=%c?P~9 zzksY*NI&-=Bq)GlScFI$2~NjZQ0&`bEY=c9js~#S*Mij05W#_g*w?TRjg17pX+N^5 zlzO?lBEZiV3DJ=#Cr>)k+RDMV9XpC+?d|C7=-|)UNeS3&YCww6N9aaV$^{-Mi_ga3 zph^KBzZH#Jv#!E3@v4b$yx3ukOI@n$pOvk&d@d!tJnr@co`fwdD&!MgN>m{1rD95K zB5bqO#$c2oCaLb{yX%oxh@mYO5%>Ud>3yiHucv-L5|$>$Fp)~3Lw{pQQMN%FfgY}? zudYNJS-!pf7&-`iXJ;plcO6G7g+^Rx5Ghj!t|s~v8q_jJ#9(-6SdjDAw)sEue_F;9Bd zR#r&fm4wQw3T*N9CeWl5I(LOxQe@0N8|Lqe1LPem;Jc0=NB4;nJmEDpG$7JvGkJnO zYz!ob3=TtIPmdtyd#{FKaeNIF@Jcr|KfS6F$ie64@oZl}G0(sk6ZjGazO;-IS{Ym& z}{a1bV6f^>h9pdl|Wn_a}=J5S515) zQ^2)8l?QOkGw@{j0&e*tCHS&ZKEIb&RKQ`Q1-GKPM1)cg9UKeRBX7`w0Rdv`+oPko zCoqs!loJ%Dx|{?V07d+m{k}DrFUw6{xDL zM0Ir)Obqq8#Z#Qv0Az_|XJfLoTC>Bvfk37?8*;F$GB9O$k{3i%^{Df7hzMB+n0Wxxba(fB` z9rB0`q!_uOHk!BEU~IcH-@`(M^$jc(2KxIkG%$#vVFrE}Cr^#w)aWS2M#nHr9kISS%H5uWC(A4E@CbZu4QlJ^s5kR$_adx@&dEAx(0Q%wWzPFC$2+M(oS9tm>Y*vZ0~e1pg7lst)ZCb2X_-%x7LQM zv9fG3kW2w=Hi(xSV=UT*s)!wVgbr6)n41HS`IBV%Q{?uer%qvvfj@m3<7dubVq#p7 zbFSMK<87wGGx4g4Z)6_u$_bSRu!NVIvKt<9J8ZF|$&KoMPUi&3;FyKwhFSzxi-3#aMl9Q)tPCvMvz*{yWrom@P_BSbD+3ytoiMu1o~na{ zE5^yrhPyqB`BSIJ?Z-~zG=V=eK8}gW2~18-336WOb-=_?mE6RuCccp=;8K^W43<&C zW2MkX;Ysl+rlciCfU7Nv^K<#_EpKi2QFqtS$lKd$@{XMeJK*l-rgU${g1kK4x#gMLkDeaI=`%{pkCWvmr=~DOEnDFv)h4D=rYAy#uNx)7GVCMpjr$wXw7+S2usOg7 z8`d*8*x3nj&N@OJEiwPy$J?7e-@xm9YDx<41&Z8^aUtFYGqKi`2iWjLon>es2R}AO z;8!d^L6)DI#M!B{n3GD?{qecpPSbJ9LG*N zJAI5sS>bMm6Rz#DN1CG)63PKPiN%lG{&m%TE*dnVA_u&fC+0xG}Ls zcqU#o@r}&-Gly080Sr7Vby?||2y}6VubB=UjYMQMicy*YGI#Azf^R;E=4K`MBZrRg zsjijE*wLfMXs}_uJ+-!-T{wQci-Tw18Q58wQxhaXSFky5r#s?do-6%yMxLt)6xHqSH56YwK!q*a1%Ki1BB`z}7%5cuvB2nh~? zxs;|mQ>y=d#<-klg*P(o@J5Cl^YPYHE)C&G3ADPr^hd$ZE`y(&J1@w|z(05;R(K{} zHSvwi{U;CV3I|o!k^+`XU2Z}e+{|rhAkm_-#Y&elyIWEW+gqBzQEm%&8jKnn8*z-L zIyTZW%XfBla^-Z9^@`15nPaN&X==R22T@$S_G;hA{V#5Xbzm_DTWWn}$cWvQ#B&Mz)7ibhgH zYHLMEbrex|Cq{;gn0o{hnw2?ry%j_Ke`-oHzcs2R4>B-NUb2X38kABFNp;l1NVqN* z;w89}D8WVgIT59U{R%N$$g}JXMd+rG;R$cW?J4HZog)Q22cGeVH+SR7tu*zuRgXGFon2C{KFhmzA^mn#rD=B!4YQF%UyFG!Qo5T6% zz<>WyHNJgZfoG3O)z|+f5)N4CG{s`SjrxJh*}jSLLKU2??cidpi%@HF)h#+0jxxYd zq#=&@>!HR=3&rjtWH^bC=_p2}hZed5bO^KrV-W_JjWNWf1QW{mG;LkJg&sqLYzuk}j{OU0N@^!1m zI`K~?;jj-c1>%#XDD}hn?QQdcgUC=)Tm{T%U-X8=h+RXanCMej zXv3cx95xPTxX5sT&HB;Kqzq?LiX%q0Ib$%&i4mVkPhQ=DFYaY)tP{U55?=E4-2^l&b558n!7pX4iG-ny|+)PP1#{7bleWSG1a}y3wsTH#Q?A&s;S2a3}A1(yr(WOYd zzo^mhFn-}AyzK39cU)@M{L=LJ^6l-3uH)!A(SzEuY9wz@M6iDl+?`zEWW5nadU|k_ zO5tRzPt3mYAvTg>tG6#D)@G&U3H+>(@HD|cy%CMaSHtk$l}L?s;-8I#mo6NW;o?!v ze_vx)*S)>H=7`z)-<3vF$;OgnW!!;M-9ywRmJ7#q)u^) zIz6GzvnJ=cnE#i@nfUz81pLEmF&gW{KRXF8zuaMpduQC#g+YIx5jt1*Y)_r(|mk&KUrg)_!lEVh=*sr@X2DB zx=?G%_+tzH=i9yb<8KO{|JyH4f-s-mh{QK<{=hYVGXL)%nurhLzrWS|$4TOsh6JI0 zcP9#8-ig4cO96Otc{3i(IpV!JCp>+{1HWDJ!&k2dGcr&;|)^6bzctt)7!!L-MuJ0yC2K>^EaaK&BGn| z_a_>Y9pjglo)`2*@JmlWCiGhII<3<>t Date: Sun, 6 Dec 2015 13:20:24 +0100 Subject: [PATCH 22/34] Small server CPU improvement Removed double clamping Keep extended properties instead of always retrieving it --- src/main/java/am2/AMEventHandler.java | 4 ++-- .../am2/particles/ParticleManagerClient.java | 19 ++++++++++--------- .../playerextensions/ExtendedProperties.java | 10 ++++------ .../java/am2/spell/components/LifeTap.java | 7 ++++--- .../java/am2/spell/components/ManaDrain.java | 14 ++++++++------ .../java/am2/spell/components/Recall.java | 9 ++++----- 6 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/main/java/am2/AMEventHandler.java b/src/main/java/am2/AMEventHandler.java index 42cae4739..4d1f50022 100644 --- a/src/main/java/am2/AMEventHandler.java +++ b/src/main/java/am2/AMEventHandler.java @@ -331,7 +331,7 @@ public void onEntityLiving(LivingUpdateEvent event){ if (ent instanceof EntityPlayer){ if (ent.worldObj.isRemote){ - int divisor = ExtendedProperties.For(ent).getAuraDelay() > 0 ? ExtendedProperties.For(ent).getAuraDelay() : 1; + int divisor = extendedProperties.getAuraDelay() > 0 ? extendedProperties.getAuraDelay() : 1; if (ent.ticksExisted % divisor == 0) AMCore.instance.proxy.particleManager.spawnAuraParticles(ent); AMCore.proxy.setViewSettings(); @@ -392,7 +392,7 @@ public void onEntityLiving(LivingUpdateEvent event){ } } - if (extendedProperties.getContingencyType() == ContingencyTypes.FALL && !ent.onGround && extendedProperties.getContingencyEffect() != null && ent.fallDistance >= 4f){ + if (!ent.onGround && ent.fallDistance >= 4f && extendedProperties.getContingencyType() == ContingencyTypes.FALL && extendedProperties.getContingencyEffect() != null){ int distanceToGround = MathUtilities.getDistanceToGround(ent, world); if (distanceToGround < -8 * ent.motionY){ extendedProperties.procContingency(); diff --git a/src/main/java/am2/particles/ParticleManagerClient.java b/src/main/java/am2/particles/ParticleManagerClient.java index 3eed567f0..701c80571 100644 --- a/src/main/java/am2/particles/ParticleManagerClient.java +++ b/src/main/java/am2/particles/ParticleManagerClient.java @@ -427,15 +427,16 @@ public void spawnAuraParticles(EntityLivingBase ent){ particleQuantity = AMCore.config.getAuraQuantity(); particleSpeed = AMCore.config.getAuraSpeed() / 10; }else{ - particleIndex = ExtendedProperties.For(ent).getAuraIndex(); - particleBehaviour = ExtendedProperties.For(ent).getAuraBehaviour(); - particleScale = ExtendedProperties.For(ent).getAuraScale() / 10; - particleAlpha = ExtendedProperties.For(ent).getAuraAlpha(); - particleDefaultColor = ExtendedProperties.For(ent).getAuraColorDefault(); - particleRandomColor = ExtendedProperties.For(ent).getAuraColorRandomize(); - particleColor = ExtendedProperties.For(ent).getAuraColor(); - particleQuantity = ExtendedProperties.For(ent).getAuraQuantity(); - particleSpeed = ExtendedProperties.For(ent).getAuraSpeed() / 10; + ExtendedProperties entProperties = ExtendedProperties.For(ent); + particleIndex = entProperties.getAuraIndex(); + particleBehaviour = entProperties.getAuraBehaviour(); + particleScale = entProperties.getAuraScale() / 10; + particleAlpha = entProperties.getAuraAlpha(); + particleDefaultColor = entProperties.getAuraColorDefault(); + particleRandomColor = entProperties.getAuraColorRandomize(); + particleColor = entProperties.getAuraColor(); + particleQuantity = entProperties.getAuraQuantity(); + particleSpeed = entProperties.getAuraSpeed() / 10; } if (particleIndex == 31) //fix radiant particle's scaling issues... diff --git a/src/main/java/am2/playerextensions/ExtendedProperties.java b/src/main/java/am2/playerextensions/ExtendedProperties.java index 19234ffc0..d8947db97 100644 --- a/src/main/java/am2/playerextensions/ExtendedProperties.java +++ b/src/main/java/am2/playerextensions/ExtendedProperties.java @@ -1101,9 +1101,10 @@ public void manaBurnoutTick(){ if (ticksSinceLastRegen >= ticksToRegen){ //mana regeneration - if (getCurrentMana() < getMaxMana()){ + float actualMaxMana = getMaxMana(); + if (getCurrentMana() < actualMaxMana){ if (entity instanceof EntityPlayer && ((EntityPlayer)entity).capabilities.isCreativeMode){ - setCurrentMana(getMaxMana()); + setCurrentMana(actualMaxMana); }else{ if (getCurrentMana() < 0){ setCurrentMana(0); @@ -1148,12 +1149,9 @@ public void manaBurnoutTick(){ } //actual mana regen - float manaToAdd = (getMaxMana() / regenTicks) * ticksSinceLastRegen; + float manaToAdd = (actualMaxMana / regenTicks) * ticksSinceLastRegen; setCurrentMana(getCurrentMana() + manaToAdd); - if (getCurrentMana() > getMaxMana()){ - setCurrentMana(getMaxMana()); - } } } //fatigue decrease diff --git a/src/main/java/am2/spell/components/LifeTap.java b/src/main/java/am2/spell/components/LifeTap.java index 132c88d3e..b55c26ede 100644 --- a/src/main/java/am2/spell/components/LifeTap.java +++ b/src/main/java/am2/spell/components/LifeTap.java @@ -56,11 +56,12 @@ public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase if (!(target instanceof EntityLivingBase)) return false; if (!world.isRemote){ double damage = SpellUtils.instance.getModifiedDouble_Mul(2, stack, caster, target, world, 0, SpellModifiers.DAMAGE); - float manaRefunded = (float)(((damage * 0.01)) * ExtendedProperties.For(caster).getMaxMana()); + ExtendedProperties casterProperties = ExtendedProperties.For(caster); + float manaRefunded = (float)(((damage * 0.01)) * casterProperties.getMaxMana()); if ((caster).attackEntityFrom(DamageSource.outOfWorld, (int)Math.floor(damage))){ - ExtendedProperties.For(caster).setCurrentMana(Math.min(ExtendedProperties.For(caster).getCurrentMana() + manaRefunded, ExtendedProperties.For(caster).getMaxMana())); - ExtendedProperties.For(caster).forceSync(); + casterProperties.setCurrentMana(casterProperties.getCurrentMana() + manaRefunded); + casterProperties.forceSync(); }else{ return false; } diff --git a/src/main/java/am2/spell/components/ManaDrain.java b/src/main/java/am2/spell/components/ManaDrain.java index 781843b27..3438086b4 100644 --- a/src/main/java/am2/spell/components/ManaDrain.java +++ b/src/main/java/am2/spell/components/ManaDrain.java @@ -28,13 +28,15 @@ public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase if (!(target instanceof EntityLivingBase)) return false; double manaStolen = 250; - if (manaStolen > ExtendedProperties.For((EntityLivingBase)target).getCurrentMana()){ - manaStolen = ExtendedProperties.For((EntityLivingBase)target).getCurrentMana(); + ExtendedProperties targetProperties = ExtendedProperties.For((EntityLivingBase)target); + if (manaStolen > targetProperties.getCurrentMana()){ + manaStolen = targetProperties.getCurrentMana(); } - ExtendedProperties.For((EntityLivingBase)target).setCurrentMana((float)(ExtendedProperties.For((EntityLivingBase)target).getCurrentMana() - manaStolen)); - ExtendedProperties.For((EntityLivingBase)target).forceSync(); - ExtendedProperties.For(caster).setCurrentMana((float)(ExtendedProperties.For(caster).getCurrentMana() + manaStolen)); - ExtendedProperties.For(caster).forceSync(); + targetProperties.setCurrentMana((float)(targetProperties.getCurrentMana() - manaStolen)); + targetProperties.forceSync(); + ExtendedProperties casterProperties = ExtendedProperties.For(caster); + casterProperties.setCurrentMana((float)(casterProperties.getCurrentMana() + manaStolen)); + casterProperties.forceSync(); return true; } diff --git a/src/main/java/am2/spell/components/Recall.java b/src/main/java/am2/spell/components/Recall.java index a5223a24d..4c237ca20 100644 --- a/src/main/java/am2/spell/components/Recall.java +++ b/src/main/java/am2/spell/components/Recall.java @@ -62,19 +62,18 @@ public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase return handleRitualReagents(ritualRunes, world, x, y, z, caster, target); } - if (!ExtendedProperties.For(caster).getMarkSet()){ + ExtendedProperties casterProperties = ExtendedProperties.For(caster); + if (!casterProperties.getMarkSet()){ if (caster instanceof EntityPlayer && !world.isRemote) ((EntityPlayer)caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.noMark"))); return false; - }else if (ExtendedProperties.For(caster).getMarkDimension() != caster.dimension){ + }else if (casterProperties.getMarkDimension() != caster.dimension){ if (caster instanceof EntityPlayer && !world.isRemote) ((EntityPlayer)caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.diffDimMark"))); return false; } if (!world.isRemote){ - ((EntityLivingBase)target).setPositionAndUpdate(ExtendedProperties - .For(caster).getMarkX(), ExtendedProperties.For(caster) - .getMarkY(), ExtendedProperties.For(caster).getMarkZ()); + ((EntityLivingBase)target).setPositionAndUpdate(casterProperties.getMarkX(), casterProperties.getMarkY(), casterProperties.getMarkZ()); } return true; } From 9ae497d5099e8a6fa97da0bcf7b804a5773877dc Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sun, 6 Dec 2015 13:45:21 +0100 Subject: [PATCH 23/34] Fixed console error on missing loop sound --- src/main/resources/assets/arsmagica2/sounds.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/resources/assets/arsmagica2/sounds.json b/src/main/resources/assets/arsmagica2/sounds.json index 4f0e992ff..57448f762 100644 --- a/src/main/resources/assets/arsmagica2/sounds.json +++ b/src/main/resources/assets/arsmagica2/sounds.json @@ -519,9 +519,7 @@ }, "spell.loop.none": { "category": "ambient", - "sounds": [ - "spell/loop/none" - ] + "sounds": [] }, "spell.loop.water": { "category": "ambient", From f0d56b235cec22304995c685ff3c1d7bdf026339 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sun, 6 Dec 2015 15:37:12 +0100 Subject: [PATCH 24/34] Fixed disarm crashing client on dedicated server --- src/main/java/am2/spell/components/Disarm.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/am2/spell/components/Disarm.java b/src/main/java/am2/spell/components/Disarm.java index b72242481..6a1201f43 100644 --- a/src/main/java/am2/spell/components/Disarm.java +++ b/src/main/java/am2/spell/components/Disarm.java @@ -45,7 +45,7 @@ public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase if (target instanceof EntityLightMage || target instanceof EntityDarkMage) return false; - if (target instanceof EntityPlayer && (!AMCore.config.getDisarmAffectsPlayers() || !MinecraftServer.getServer().isPVPEnabled())) + if (target instanceof EntityPlayer && (!AMCore.config.getDisarmAffectsPlayers() || (!world.isRemote && !MinecraftServer.getServer().isPVPEnabled()))) return false; if (target instanceof EntityPlayer && ((EntityPlayer)target).getHeldItem() != null && !target.worldObj.isRemote){ From b754ad3509cb040a4b53a2d7bfd5ae863a75d196 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sun, 6 Dec 2015 19:47:10 +0100 Subject: [PATCH 25/34] Code cleanup Refactored boolean test for ((!a * b) + a) in (a + b) --- src/main/java/am2/entities/EntityThrownSickle.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/am2/entities/EntityThrownSickle.java b/src/main/java/am2/entities/EntityThrownSickle.java index 9f91c83bd..ba4bfb090 100644 --- a/src/main/java/am2/entities/EntityThrownSickle.java +++ b/src/main/java/am2/entities/EntityThrownSickle.java @@ -211,7 +211,7 @@ protected void HitObject(MovingObjectPosition movingobjectposition){ if (getThrowingEntity() != null && !this.entityHits.contains(movingobjectposition.entityHit.getEntityId())){ this.entityHits.add(movingobjectposition.entityHit.getEntityId()); if (getThrowingEntity() instanceof EntityPlayer){ - if (movingobjectposition.entityHit instanceof EntityPlayer && ((!getThrowingEntity().worldObj.isRemote && !MinecraftServer.getServer().isPVPEnabled()) || getThrowingEntity().worldObj.isRemote)) + if (movingobjectposition.entityHit instanceof EntityPlayer && (getThrowingEntity().worldObj.isRemote || !MinecraftServer.getServer().isPVPEnabled())) return; movingobjectposition.entityHit.attackEntityFrom(DamageSources.causeEntityCactusDamage(getThrowingEntity(), true), 10); }else{ From 2291fbc8d77f9a14a4907a393aa4091677ea100c Mon Sep 17 00:00:00 2001 From: LemADEC Date: Fri, 11 Dec 2015 01:02:23 +0100 Subject: [PATCH 26/34] Fixed server crash with appropriation spell --- .../am2/spell/components/Appropriation.java | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/main/java/am2/spell/components/Appropriation.java b/src/main/java/am2/spell/components/Appropriation.java index 3107f5d2d..8a00e6612 100644 --- a/src/main/java/am2/spell/components/Appropriation.java +++ b/src/main/java/am2/spell/components/Appropriation.java @@ -51,17 +51,25 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl return false; ItemStack originalSpellStack = getOriginalSpellStack((EntityPlayer)caster); - if (originalSpellStack == null) + if (originalSpellStack == null){ return false; + } + + if (originalSpellStack.stackTagCompound == null){ + return false; + } Block block = world.getBlock(blockx, blocky, blockz); - if (block == null) + if (block == null){ return false; + } - for (String s : AMCore.config.getAppropriationBlockBlacklist()) - if (block.getUnlocalizedName() == s) + for (String s : AMCore.config.getAppropriationBlockBlacklist()){ + if (block.getUnlocalizedName() == s){ return false; + } + } if (!world.isRemote){ if (originalSpellStack.stackTagCompound.hasKey(storageKey)){ @@ -90,12 +98,14 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl } } - if (world.isAirBlock(blockx, blocky, blockz) || !world.getBlock(blockx, blocky, blockz).getMaterial().isSolid()) + if (world.isAirBlock(blockx, blocky, blockz) || !world.getBlock(blockx, blocky, blockz).getMaterial().isSolid()){ restore((EntityPlayer)caster, world, originalSpellStack, blockx, blocky, blockz, impactX, impactY, impactZ); + } }else{ - if (block == null || block.getBlockHardness(world, blockx, blocky, blockz) == -1.0f) + if (block == null || block.getBlockHardness(world, blockx, blocky, blockz) == -1.0f){ return false; + } NBTTagCompound data = new NBTTagCompound(); data.setString(storageType, "block"); @@ -109,12 +119,11 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl te.writeToNBT(teData); data.setTag("tileEntity", teData); - //essentially reset the tile entity before destroying the block - this corrects several issues such as inventory items dropping - //we don't want this as the inventory items are already saved in the NBT! + // remove tile entity first to prevent content dropping which is already saved in the NBT try{ - world.setTileEntity(blockx, blocky, blockz, te.getClass().newInstance()); - }catch (Throwable e){ - e.printStackTrace(); + world.removeTileEntity(blockx, blocky, blockz); + }catch (Throwable exception){ + exception.printStackTrace(); } } From f89407a4a4721ba25fa1053e135d68abf0421779 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Fri, 11 Dec 2015 02:44:10 +0100 Subject: [PATCH 27/34] Improved entangle balance It was starting at 32 seconds without any duration modifier nor armor bonus, up to 10 minutes with 3x duration and top tier armor. In PvP, 30 seconds is more than enough to kill a static target. Burnout has been increased, so you can't spam the target with that spell. Duration was reduced to 10 seconds default + 10% of default duration modifiers (so up to ~40 seconds with 3x duration modifier, no armor). --- src/main/java/am2/spell/components/Entangle.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/am2/spell/components/Entangle.java b/src/main/java/am2/spell/components/Entangle.java index 8a060c79c..a8de2efaa 100644 --- a/src/main/java/am2/spell/components/Entangle.java +++ b/src/main/java/am2/spell/components/Entangle.java @@ -33,7 +33,7 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl @Override public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target){ if (target instanceof EntityLivingBase){ - int duration = SpellUtils.instance.getModifiedInt_Mul(BuffList.default_buff_duration, stack, caster, target, world, 0, SpellModifiers.DURATION); + int duration = 140 + SpellUtils.instance.getModifiedInt_Mul(BuffList.default_buff_duration / 10, stack, caster, target, world, 0, SpellModifiers.DURATION); duration = SpellUtils.instance.modifyDurationBasedOnArmor(caster, duration); int x = (int)Math.floor(target.posX); @@ -58,7 +58,7 @@ public float manaCost(EntityLivingBase caster){ @Override public float burnout(EntityLivingBase caster){ - return ArsMagicaApi.instance.getBurnoutFromMana(manaCost(caster)); + return ArsMagicaApi.instance.getBurnoutFromMana(manaCost(caster)) * 4; } @Override From f462cdb0d76cabf6ffdeacaad66777508d3fcb33 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Fri, 11 Dec 2015 03:13:26 +0100 Subject: [PATCH 28/34] Added option to support server staff When disabled, players in creative mode can't be targetted by other players. --- src/main/java/am2/configuration/AMConfig.java | 10 ++++++++++ src/main/java/am2/spell/SpellHelper.java | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/src/main/java/am2/configuration/AMConfig.java b/src/main/java/am2/configuration/AMConfig.java index 3baf224be..651cbbef1 100644 --- a/src/main/java/am2/configuration/AMConfig.java +++ b/src/main/java/am2/configuration/AMConfig.java @@ -76,6 +76,8 @@ public class AMConfig extends Configuration{ private final String KEY_EnableWitchwoodForest = "Enable_Witchwood_Forests"; + private final String KEY_allowCreativeTargets = "Allow_Creative_Targets"; + /** * Beta Particles **/ @@ -174,6 +176,8 @@ public class AMConfig extends Configuration{ private int[] worldgenBlacklist; private boolean enableWitchwoodForest; private int witchwoodForestRarity; + + private boolean allowCreativeTargets; private String[] appropriationBlockBlacklist; private Class[] appropriationMobBlacklist; @@ -292,6 +296,8 @@ public void init(){ enableWitchwoodForest = get(CATEGORY_GENERAL, KEY_EnableWitchwoodForest, true, "Disable this if you prefer the witchwood forest to not generate").getBoolean(true); witchwoodForestRarity = get(CATEGORY_GENERAL, KEY_WitchwoodForestRarity, 6, "Sets how rare witchwood forests are. Lower is more rare.").getInt(); + allowCreativeTargets = get(CATEGORY_GENERAL, KEY_allowCreativeTargets, true, "Disable this to prevent spell effects on creative players").getBoolean(true); + moonstoneMeteorsDestroyTerrain = get(CATEGORY_GENERAL, KEY_moonstoneMeteorsDestroyTerrain, true, "Should moonstone meteors destroy terrain when landing? Keep in mind they will never land on anything other than grass.").getBoolean(true); suggestSpellNames = get(CATEGORY_GENERAL, KEY_moonstoneMeteorsDestroyTerrain, true, "Set this to true to allow AM2 to get random spell names from Seventh Sanctum, and suggest them when naming spells. Naturally, an internet connection is required. Keep in mind, while I try to keep things family friendly, it's possible that not all names generated are so.").getBoolean(true); @@ -646,6 +652,10 @@ public int getWitchwoodForestRarity(){ return this.witchwoodForestRarity; } + public boolean getAllowCreativeTargets(){ + return this.allowCreativeTargets; + } + //==================================================================================== // Getters - Aura //==================================================================================== diff --git a/src/main/java/am2/spell/SpellHelper.java b/src/main/java/am2/spell/SpellHelper.java index 9fffe606f..21e7d0a4e 100644 --- a/src/main/java/am2/spell/SpellHelper.java +++ b/src/main/java/am2/spell/SpellHelper.java @@ -31,6 +31,7 @@ import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; @@ -92,6 +93,10 @@ public SpellCastResult applyStageToEntity(ItemStack stack, EntityLivingBase cast ISpellShape stageShape = SpellUtils.instance.getShapeForStage(stack, 0); if (stageShape == null) return SpellCastResult.MALFORMED_SPELL_STACK; + if ((!AMCore.config.getAllowCreativeTargets()) && target instanceof EntityPlayerMP && ((EntityPlayerMP) target).capabilities.isCreativeMode) { + return SpellCastResult.EFFECT_FAILED; + } + ISpellComponent[] components = SpellUtils.instance.getComponentsForStage(stack, 0); boolean appliedOneComponent = false; From 97764f0eea2c197a779084110e08c0e434e40a66 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Fri, 11 Dec 2015 09:51:51 +0100 Subject: [PATCH 29/34] Code cleanup Create dummy player only once --- src/main/java/am2/spell/components/Dig.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/am2/spell/components/Dig.java b/src/main/java/am2/spell/components/Dig.java index 4b8a65075..f1c1cbdc6 100644 --- a/src/main/java/am2/spell/components/Dig.java +++ b/src/main/java/am2/spell/components/Dig.java @@ -78,21 +78,21 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl int miningLevel = 2 + SpellUtils.instance.countModifiers(SpellModifiers.MINING_POWER, stack, 0); if (harvestLevel > miningLevel) return false; - if (ForgeEventFactory.doPlayerHarvestCheck(DummyEntityPlayer.fromEntityLiving(caster), block, true)){ + EntityPlayer casterPlayer = DummyEntityPlayer.fromEntityLiving(caster); + if (ForgeEventFactory.doPlayerHarvestCheck(casterPlayer, block, true)){ float xMana = block.getBlockHardness(world, blockx, blocky, blockz) * hardnessManaFactor; float xBurnout = ArsMagicaApi.instance.getBurnoutFromMana(xMana); if (!world.isRemote){ - EntityPlayerMP casterPlayer = (EntityPlayerMP)DummyEntityPlayer.fromEntityLiving(caster); - BreakEvent event = ForgeHooks.onBlockBreakEvent(world, casterPlayer.theItemInWorldManager.getGameType(), casterPlayer, blockx, blocky, blockz); + BreakEvent event = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP)casterPlayer).theItemInWorldManager.getGameType(), (EntityPlayerMP)casterPlayer, blockx, blocky, blockz); if (event.isCanceled()){ return false; } - block.onBlockHarvested(world, blockx, blocky, blockz, meta, DummyEntityPlayer.fromEntityLiving(caster)); - boolean flag = block.removedByPlayer(world, DummyEntityPlayer.fromEntityLiving(caster), blockx, blocky, blockz, true); + block.onBlockHarvested(world, blockx, blocky, blockz, meta, casterPlayer); + boolean flag = block.removedByPlayer(world, casterPlayer, blockx, blocky, blockz, true); if(flag){ block.onBlockDestroyedByPlayer(world, blockx, blocky, blockz, meta); - block.harvestBlock(world, DummyEntityPlayer.fromEntityLiving(caster), blockx, blocky, blockz, meta); + block.harvestBlock(world, casterPlayer, blockx, blocky, blockz, meta); } } From 1e0d00e125bbafd389ffa47e164a039d654e308d Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sat, 12 Dec 2015 01:55:25 +0100 Subject: [PATCH 30/34] Fixed appropriation spell to respect spawn --- .../am2/spell/components/Appropriation.java | 88 ++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/src/main/java/am2/spell/components/Appropriation.java b/src/main/java/am2/spell/components/Appropriation.java index 8a00e6612..e91fd662b 100644 --- a/src/main/java/am2/spell/components/Appropriation.java +++ b/src/main/java/am2/spell/components/Appropriation.java @@ -1,28 +1,39 @@ package am2.spell.components; import am2.AMCore; +import am2.api.ArsMagicaApi; import am2.api.spell.component.interfaces.ISpellComponent; import am2.api.spell.enums.Affinity; import am2.blocks.BlocksCommonProxy; import am2.items.ItemSpellBook; import am2.particles.AMParticle; import am2.particles.ParticleOrbitPoint; +import am2.playerextensions.ExtendedProperties; import am2.spell.SpellUtils; +import am2.utility.DummyEntityPlayer; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.IBossDisplayData; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.init.Items; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.stats.StatList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.event.ForgeEventFactory; +import net.minecraftforge.event.world.BlockEvent.BreakEvent; import java.util.EnumSet; +import java.util.List; import java.util.Random; public class Appropriation implements ISpellComponent{ @@ -99,7 +110,71 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl } if (world.isAirBlock(blockx, blocky, blockz) || !world.getBlock(blockx, blocky, blockz).getMaterial().isSolid()){ + + // save current spell + NBTTagCompound nbt = null; + if (stack.getTagCompound() != null){ + nbt = (NBTTagCompound)stack.getTagCompound().copy(); + } + + + EntityPlayerMP casterPlayer = (EntityPlayerMP)DummyEntityPlayer.fromEntityLiving(caster); + world.captureBlockSnapshots = true; restore((EntityPlayer)caster, world, originalSpellStack, blockx, blocky, blockz, impactX, impactY, impactZ); + world.captureBlockSnapshots = false; + + // save new spell data + NBTTagCompound newNBT = null; + if (stack.getTagCompound() != null){ + newNBT = (NBTTagCompound)stack.getTagCompound().copy(); + } + + net.minecraftforge.event.world.BlockEvent.PlaceEvent placeEvent = null; + List blockSnapshots = (List) world.capturedBlockSnapshots.clone(); + world.capturedBlockSnapshots.clear(); + + // restore original item data for event + if (nbt != null){ + stack.setTagCompound(nbt); + } + if (blockSnapshots.size() > 1){ + placeEvent = ForgeEventFactory.onPlayerMultiBlockPlace(casterPlayer, blockSnapshots, ForgeDirection.UNKNOWN); + } else if (blockSnapshots.size() == 1){ + placeEvent = ForgeEventFactory.onPlayerBlockPlace(casterPlayer, blockSnapshots.get(0), ForgeDirection.UNKNOWN); + } + + if (placeEvent != null && (placeEvent.isCanceled())){ + // revert back all captured blocks + for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : blockSnapshots){ + world.restoringBlockSnapshots = true; + blocksnapshot.restore(true, false); + world.restoringBlockSnapshots = false; + } + return false; + } else { + // Change the stack to its new content + if (nbt != null){ + stack.setTagCompound(newNBT); + } + + for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : blockSnapshots){ + int blockX = blocksnapshot.x; + int blockY = blocksnapshot.y; + int blockZ = blocksnapshot.z; + int metadata = world.getBlockMetadata(blockX, blockY, blockZ); + int updateFlag = blocksnapshot.flag; + Block oldBlock = blocksnapshot.replacedBlock; + Block newBlock = world.getBlock(blockX, blockY, blockZ); + if (newBlock != null && !(newBlock.hasTileEntity(metadata))){ // Containers get placed automatically + newBlock.onBlockAdded(world, blockX, blockY, blockZ); + } + + world.markAndNotifyBlock(blockX, blockY, blockZ, null, oldBlock, newBlock, updateFlag); + } + } + world.capturedBlockSnapshots.clear(); + + // restore((EntityPlayer)caster, world, originalSpellStack, blockx, blocky, blockz, impactX, impactY, impactZ); } }else{ @@ -111,7 +186,18 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl data.setString(storageType, "block"); //data.setString("blockName", block.getUnlocalizedName().replace("tile.", "")); data.setInteger("blockID", Block.getIdFromBlock(block)); - data.setInteger("meta", world.getBlockMetadata(blockx, blocky, blockz)); + int meta = world.getBlockMetadata(blockx, blocky, blockz); + data.setInteger("meta", meta); + + EntityPlayerMP casterPlayer = (EntityPlayerMP)DummyEntityPlayer.fromEntityLiving(caster); + if (!ForgeEventFactory.doPlayerHarvestCheck(casterPlayer, block, true)){ + return false; + } + + BreakEvent event = ForgeHooks.onBlockBreakEvent(world, casterPlayer.theItemInWorldManager.getGameType(), casterPlayer, blockx, blocky, blockz); + if (event.isCanceled()){ + return false; + } TileEntity te = world.getTileEntity(blockx, blocky, blockz); if (te != null){ From 25dcf27d37d6420cec057e3dc67ba89747c84544 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sat, 12 Dec 2015 02:40:48 +0100 Subject: [PATCH 31/34] Fixed control menu translation --- src/main/resources/assets/arsmagica2/lang/en_US.lang | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/resources/assets/arsmagica2/lang/en_US.lang b/src/main/resources/assets/arsmagica2/lang/en_US.lang index 0baf0e29d..792083b22 100644 --- a/src/main/resources/assets/arsmagica2/lang/en_US.lang +++ b/src/main/resources/assets/arsmagica2/lang/en_US.lang @@ -518,7 +518,14 @@ am2.tooltip.wrongWrenchMode=The wrench isn't in the right mode to interact with am2.tooltip.wtrbrth=Water Breathing am2.tooltip.wtrwalk=Water Walking -key.activateAffinityAbility=Affinity Ability +# Control keys +key.am2.category=ArsMagica2 +key.ActivateAffinityAbility=Activate affinity ability +key.AuraCustomization=Aura customization +key.ShapeGroups=Shape groups +key.SpellBookNext=Spell book, Next +key.SpellBookPrev=Spell book, Previous +key.ToggleManaDisplay=Toggle mana display #guis am2.gui.Affinity=Affinity From 96c86d525cdecdd509e6dc9a97b2cc59bbd52e67 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Mon, 14 Dec 2015 01:21:54 +0100 Subject: [PATCH 32/34] Fixed crash with disabled mods Added a proper check for OptiFine presence (proper fix) Adjusted Thaumcraft and DragonAPI too (partial fix) Bumped coremod version to 0.0.3 --- .../am2/preloader/AM2PreloaderContainer.java | 56 ++++++++++++++----- .../am2/preloader/BytecodeTransformers.java | 8 +-- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/src/main/java/am2/preloader/AM2PreloaderContainer.java b/src/main/java/am2/preloader/AM2PreloaderContainer.java index 2fb176085..81ec7db0e 100644 --- a/src/main/java/am2/preloader/AM2PreloaderContainer.java +++ b/src/main/java/am2/preloader/AM2PreloaderContainer.java @@ -18,7 +18,8 @@ public class AM2PreloaderContainer extends DummyModContainer implements IFMLLoad private final ModMetadata md = new ModMetadata(); public static boolean foundThaumcraft = false; - public static boolean foundOptifine = false; + private static boolean foundOptiFine = false; + private static boolean confirmedOptiFine = false; public static boolean foundDragonAPI = false; public static boolean isDevEnvironment = false; @@ -46,7 +47,7 @@ public String getName(){ @Override public String getVersion(){ - return "0.0.2"; + return "0.0.3"; } @Override @@ -82,6 +83,8 @@ public String getSetupClass(){ @Override public void injectData(Map data){ + // This is very crude check for mods presence using filename. + // Some mods may refer to others in their name, so we'll to confirm those assumption with class presence check. File loc = (File)data.get("mcLocation"); LogHelper.trace("MC located at: " + loc.getAbsolutePath()); @@ -89,17 +92,21 @@ public void injectData(Map data){ File mcFolder = new File(loc.getAbsolutePath() + File.separatorChar + "mods"); File[] subfiles = mcFolder.listFiles(); - for (File f : subfiles){ - if (f.getName() != null){ - if (f.getName().toLowerCase().contains("thaumcraft")){ - LogHelper.info("Core: Located Thaumcraft"); - foundThaumcraft = true; - }else if (f.getName().toLowerCase().contains("optifine")){ - LogHelper.info("Core: Located Optifine"); - foundOptifine = true; - }else if (f.getName().toLowerCase().contains("dragonapi")){ - LogHelper.info("Core: Located DragonAPI"); - foundDragonAPI = true; + for (File file : subfiles){ + String name = file.getName(); + if (name != null) { + name = name.toLowerCase(); + if (name.endsWith(".jar") || name.endsWith(".zip")){ + if (name.contains("thaumcraft")){ + LogHelper.info("Core: Located Thaumcraft in " + file.getName()); + foundThaumcraft = true; + }else if (name.contains("optifine")){ + LogHelper.info("Core: Located OptiFine in " + file.getName() + ". We'll to confirm that..."); + foundOptiFine = true; + }else if (name.contains("dragonapi")){ + LogHelper.info("Core: Located DragonAPI in " + file.getName()); + foundDragonAPI = true; + } } } } @@ -110,4 +117,27 @@ public String getAccessTransformerClass(){ return null; } + public static boolean isOptiFinePresent(){ + if (!confirmedOptiFine && foundOptiFine){ + // Check presence of OptiFine core classes + try{ + Class.forName("optifine.OptiFineForgeTweaker"); + } + catch (ClassNotFoundException exception1){ + try{ + Class.forName("optifine.OptiFineTweaker"); + } + catch (ClassNotFoundException exception2){ + foundOptiFine = false; + } + } + if (foundOptiFine){ + LogHelper.info("Core: OptiFine presence has been confirmed."); + } else { + LogHelper.info("Core: OptiFine doesn't seem to be there actually."); + } + confirmedOptiFine = true; + } + return foundOptiFine; + } } diff --git a/src/main/java/am2/preloader/BytecodeTransformers.java b/src/main/java/am2/preloader/BytecodeTransformers.java index f3c83407a..8f2e7dc6b 100644 --- a/src/main/java/am2/preloader/BytecodeTransformers.java +++ b/src/main/java/am2/preloader/BytecodeTransformers.java @@ -2,13 +2,12 @@ import am2.LogHelper; import net.minecraft.launchwrapper.IClassTransformer; + import org.apache.logging.log4j.Level; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.*; -import org.objectweb.asm.Type; - import java.lang.reflect.Field; import java.util.Iterator; @@ -276,7 +275,7 @@ private byte[] alterEntityRenderer(byte[] bytes, boolean is_obfuscated){ } if (target != null){ - int iRegister = AM2PreloaderContainer.foundOptifine ? 3 : 2; + int iRegister = AM2PreloaderContainer.isOptiFinePresent() ? 3 : 2; VarInsnNode aLoad = new VarInsnNode(Opcodes.ALOAD, 0); VarInsnNode fLoad = new VarInsnNode(Opcodes.FLOAD, 1); @@ -860,7 +859,7 @@ private byte[] alterS1DPacketEntityEffect(byte[] bytes, boolean is_obfuscated, S method3_name.setVal("func_149427_e", false); method3_name.setVal("e", true); - String method3_desc = "()B"; + // String method3_desc = "()B"; String method3_newdesc = "()I"; @@ -1123,7 +1122,6 @@ private byte[] alterS1EPacketRemoveEntityEffect(byte[] bytes, boolean is_obfusca if (mn.name.equals(method1_name.getVal(is_obfuscated)) && mn.desc.equals(method1_desc.getVal(is_obfuscated))){ // readPacketData AbstractInsnNode target = null; - AbstractInsnNode target2 = null; LogHelper.debug("Core: Located target method " + mn.name + mn.desc); Iterator instructions = mn.instructions.iterator(); From c54f7afca6a2308897bb3dce4e703c8387be191e Mon Sep 17 00:00:00 2001 From: LemADEC Date: Mon, 14 Dec 2015 01:25:53 +0100 Subject: [PATCH 33/34] Fixed stack overflow with Arcana guardian retaliation When players spawn 2+ bosses, stack overflow occurs after close proximity attack between 2 bosses (retaliation inception) Fixed arcana shield to actually absorb damages --- src/main/java/am2/bosses/AM2Boss.java | 2 +- src/main/java/am2/bosses/EntityArcaneGuardian.java | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/am2/bosses/AM2Boss.java b/src/main/java/am2/bosses/AM2Boss.java index 73e7cdbe6..d4f5334d4 100644 --- a/src/main/java/am2/bosses/AM2Boss.java +++ b/src/main/java/am2/bosses/AM2Boss.java @@ -129,7 +129,7 @@ public boolean canBeCollidedWith(){ public boolean attackEntityFrom(DamageSource par1DamageSource, float par2){ if (par1DamageSource == DamageSource.inWall){ - if (!worldObj.isRemote){ + if (!worldObj.isRemote){// dead code? (calling canSnowAt() without using the result) could it be a buggy upgrade to 1.7.10? for (int i = -1; i <= 1; ++i){ for (int j = 0; j < 3; ++j){ for (int k = -1; k <= 1; ++k){ diff --git a/src/main/java/am2/bosses/EntityArcaneGuardian.java b/src/main/java/am2/bosses/EntityArcaneGuardian.java index b47a7ac24..ebcbf2fcd 100644 --- a/src/main/java/am2/bosses/EntityArcaneGuardian.java +++ b/src/main/java/am2/bosses/EntityArcaneGuardian.java @@ -96,13 +96,17 @@ public boolean attackEntityFrom(DamageSource par1DamageSource, float par2){ return super.attackEntityFrom(par1DamageSource, par2); } - if (checkRuneRetaliation(par1DamageSource)) + if (checkRuneRetaliation(par1DamageSource)){ return super.attackEntityFrom(par1DamageSource, par2); - return false; + } + return super.attackEntityFrom(par1DamageSource, par2 * 0.8F); } private boolean checkRuneRetaliation(DamageSource damagesource){ Entity source = damagesource.getSourceOfDamage(); + if (source instanceof EntityArcaneGuardian) { + return true; + } double deltaX = source.posX - this.posX; double deltaZ = source.posZ - this.posZ; @@ -132,6 +136,7 @@ private boolean checkRuneRetaliation(DamageSource damagesource){ source.motionY = vertSpeed; source.attackEntityFrom(DamageSource.causeMobDamage(this), 2); + return false; } } return true; From ea595d9f990ab8adbaa1fbf02475ed51b4d57669 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Sun, 20 Dec 2015 13:09:38 +0100 Subject: [PATCH 34/34] Code cleanup Minor speed optimisation --- src/main/java/am2/AMEventHandler.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/am2/AMEventHandler.java b/src/main/java/am2/AMEventHandler.java index 4d1f50022..caeb4f74c 100644 --- a/src/main/java/am2/AMEventHandler.java +++ b/src/main/java/am2/AMEventHandler.java @@ -610,14 +610,18 @@ public void onEntityHurt(LivingHurtEvent event){ } } - if (event.source.getSourceOfDamage() instanceof EntityPlayer && ((EntityPlayer)event.source.getSourceOfDamage()).inventory.armorInventory[2] != null && ((EntityPlayer)event.source.getSourceOfDamage()).inventory.armorInventory[2].getItem() == ItemsCommonProxy.earthGuardianArmor && ((EntityPlayer)event.source.getSourceOfDamage()).getCurrentEquippedItem() == null){ + Entity entitySource = event.source.getSourceOfDamage(); + if ( entitySource instanceof EntityPlayer + && ((EntityPlayer)entitySource).inventory.armorInventory[2] != null + && ((EntityPlayer)entitySource).inventory.armorInventory[2].getItem() == ItemsCommonProxy.earthGuardianArmor + && ((EntityPlayer)entitySource).getCurrentEquippedItem() == null ){ event.ammount += 4; - double deltaZ = event.entityLiving.posZ - event.source.getSourceOfDamage().posZ; - double deltaX = event.entityLiving.posX - event.source.getSourceOfDamage().posX; + double deltaZ = event.entityLiving.posZ - entitySource.posZ; + double deltaX = event.entityLiving.posX - entitySource.posX; double angle = Math.atan2(deltaZ, deltaX); - double speed = ((EntityPlayer)event.source.getSourceOfDamage()).isSprinting() ? 3 : 2; - double vertSpeed = ((EntityPlayer)event.source.getSourceOfDamage()).isSprinting() ? 0.5 : 0.325; + double speed = ((EntityPlayer)entitySource).isSprinting() ? 3 : 2; + double vertSpeed = ((EntityPlayer)entitySource).isSprinting() ? 0.5 : 0.325; if (event.entityLiving instanceof EntityPlayer){ AMNetHandler.INSTANCE.sendVelocityAddPacket(event.entityLiving.worldObj, event.entityLiving, speed * Math.cos(angle), vertSpeed, speed * Math.sin(angle)); @@ -641,9 +645,8 @@ public void onEntityHurt(LivingHurtEvent event){ if (ent.isPotionActive(BuffList.fury.id)) event.ammount /= 2; - if (event.source.getSourceOfDamage() != null && - event.source.getSourceOfDamage() instanceof EntityLivingBase && - ((EntityLivingBase)event.source.getSourceOfDamage()).isPotionActive(BuffList.shrink)) + if ( entitySource instanceof EntityLivingBase + && ((EntityLivingBase)entitySource).isPotionActive(BuffList.shrink)) event.ammount /= 2; }