diff --git a/.gitignore b/.gitignore index 287e293b..f5c30521 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,6 @@ Thumbs.db #gradle stuff /.gradle /build/ -/run/ /run*/ /ui/ gradle-app.setting diff --git a/build.properties b/build.properties index 85262113..632a042d 100644 --- a/build.properties +++ b/build.properties @@ -1,8 +1,8 @@ minecraft_version=1.7.10 -forge_version=10.13.1.1217 +forge_version=10.13.2.1235 mantle_version=0.3.1.jenkins176 -CCLIB_version=1.1.1.95 -NEI_version=1.0.2.15 -ccc_version=1.0.2.9 +CCLIB_version=1.1.1.99 +NEI_version=1.0.3.66 +ccc_version=1.0.4.29 mod_version=1.7.experimental waila_version=1.5.3_1.7.10 \ No newline at end of file diff --git a/resources/assets/tinker/lang/ko_KR.lang b/resources/assets/tinker/lang/ko_KR.lang index cb57a252..85a0356f 100644 --- a/resources/assets/tinker/lang/ko_KR.lang +++ b/resources/assets/tinker/lang/ko_KR.lang @@ -767,26 +767,25 @@ gui.toolstation18=남은 업그레이드 횟수: gui.toolstation19=데미지 감소: gui.toolstation20=보호: -gui.toolstation.pickaxe.desc=곡괭이는 채광에 필요한 도구입니다. 돌과 광석블럭을 빠르게 부숩니다.\n\n필요 부품:\n- 곡괭이머리\n- 조임쇠\n- 손잡이 -gui.toolstation.shovel.desc=삽은 땅을팔때 필요한 도구입니다. 흙과모래 그리고 눈을 빠르게 부숩니다.\n\nRequired parts:\n- Shovel Head\n- Handle -gui.toolstation.hatchet.desc=손도끼는 벌목에 필요한 도구입니다. 나무와 잎을 빠르게 부숩니다.\n\nRequired parts:\n- Axe Head\n- Handle -gui.toolstation.mattock.desc=매톡은 다양한 농업용도구입니다. 나무,흙,식물들을 빠르게 부숩니다.\n\nSpecial Ability: Hoe\n\nRequired parts:\n- Axe Head\n- Shovel Head\n- Handle -gui.toolstation.broadsword.desc=브로드소드는 방어용검입니다.블로킹으로 데미지를 반으로 반감시켜줍니다.\n\nSpecial Ability: Block\nDamage: Moderate\nDurability: High\n\nRequired parts:\n- Sword Blade\n- Wide Guard\n- Handle -gui.toolstation.longsword.desc=The Longsword is an offensive weapon. It is often used for charging into battle at full speed.\n\nNatural Ability:\n- Charge Boost\nSpecial Ability: Lunge\n\nDamage: Moderate\nDurability: Moderate -gui.toolstation.rapier.desc=The Rapier is a special weapon that relies on quick strikes to defeat foes.\n\nNatural Abilities:\n- Armor Pierce\n- Quick Strike\n- Charge Boost\nSpecial Ability:\n- Backpedal\n\nDamage: Low\nDurability: Low -gui.toolstation.dagger.desc=The Dagger is a short blade that can be thrown.\n\nSpecial Ability:\n- Throw Item\n\nDamage: Low\nDurability: Moderate\n\nRequired parts:\n- Knife Blade\n- Crossbar\n- Handle -gui.toolstation.fryingpan.desc=The Frying Pan is a heavy weapon that uses sheer weight to stun foes.\n\nSpecial Ability: Block\nNatural Ability: Heavy\nShiftrClick: Place Frying Pan\nDamage: Low\nDurability: High\n\nRequired parts:\n- Pan\n- Handle -gui.toolstation.battlesign.desc=The Battlesign is an advance in weapon technology worthy of Zombie Pigmen everywhere.\n\nSpecial Ability:\nDamage Reflector\n\nNatural Ability: Writable\n\nDamage: Low\nDurability: Average -gui.toolstation.chisel.desc=The Chisel is a utility tool that carves shapes into blocks.\n\nCrafting Grid:\n- Shape Items\nSpecial Ability: Chisel\nDurability: Average\n\nRequired parts:\n- Chisel Head\n- Handle -gui.toolstation.shortbow.desc=The Shortbow is a ranged weapon. It fires arrows quickly and precisely at its foes.\n\nDraw Speed: Quick\n\nRequired parts:\n- Tool Rod\n- Bowstring\n- Tool Rod -gui.toolstation.arrow.desc=Arrows are projectiles usually fired from bows.\n\nRequired parts:\n- Arrowhead\n- Tool Rod\n- Fletching -gui.toolstation.hammer.desc=The Hammer is a broad mining tool. It harvests blocks in a wide range and is effective against undead.\n\nNatural Abilities:\nArea of Effect\n- (3x3)\n- Smite\n\nDurability: High -gui.toolstation.lumberaxe.desc=The Lumber Axe is a broad chopping tool. It can fell entire trees or gather wood in a wide range.\n\nNatural Abilities:\nArea of Effect\n- Fell Trees\n- (3x3x3)\n\nDurability: Average -gui.toolstation.excavator.desc=The Excavator is a broad digging tool. It harvests soil and snow in a wide range.\n\nNatural Ability:\n- Area of Effect\n- (3x3)\n\nDurability: Average -gui.toolstation.scythe.desc=The Scythe is a broad reaping tool. It is effective on plants and attacks enemies in a wide range.\n\nNatural Ability:\nArea of Effect\n- (3x3x3)\n\nDurability: Average\nDamage: Low, AoE -gui.toolstation.cleaver.desc=The Cleaver is a heavy defensive weapon. It has powerful strikes, but is difficult to wield.\n\nSpecial Ability: Block\nNatural Ability:\n- Beheading\n\nDamage: High\nDurability: Average -gui.toolstation.battleaxe.desc=The Battleaxe is a heavy offensive weapon. It is capable of bringing down small trees and can send foes flying.\n\nSpecial Ability: Block\nNatural Abilities:" "\n- Knockback\n- Area of Effect\n- (1x9)\n\nDamage: Average\nDurability: Average - +gui.toolstation.pickaxe.desc=곡괭이는 채광에 필요한 도구입니다. 돌과 광석블럭을 빠르게 부숩니다.\n\n필요부품:\n- 곡괭이머리\n- 조임쇠\n- 손잡이 +gui.toolstation.shovel.desc=삽은 땅을팔때 필요한 도구입니다. 흙과모래 그리고 눈을 빠르게 부숩니다.\n\n필요부품:\n- 삽 머리\n-손잡이 +gui.toolstation.hatchet.desc=손도끼는 벌목에 필요한 도구입니다. 나무와 잎을 빠르게 부숩니다.\n\n필요부품:\n- 도끼 머리\n-손잡이 +gui.toolstation.mattock.desc=매톡은 다양한 농업용도구입니다. 나무,흙,식물들을 빠르게 부숩니다.\n\n특수능력: 괭이\n\n필요부품:\n- 도끼 머리\n- 삽 머리\n-손잡이 +gui.toolstation.broadsword.desc=브로드소드는 방어형 검입니다.블로킹으로 데미지를 반으로 반감시켜줍니다.\n\n특수능력: 블럭\n데미지: 보통\n내구도: 높음\n\n필요부품:\n- 검날\n- 와이드가드\n- 손잡이 +gui.toolstation.longsword.desc=롱소드는 공격형 검입니다. 종종 최고속도로 전투를 합니다..\n\n기본효과:\n- 차지 부스트\n특수능력: 돌진\n\n데미지: 보통\n내구도: 보통 +gui.toolstation.rapier.desc=The Rapier is a special weapon that relies on quick strikes to defeat foes.\n\n기본효과:\n- 방어력 무시\n- 빠르게 찌름\n- 차지부스트\n특수능력:\n- 철회\n\n데미지: 낮음\n내구도: 낮음 +gui.toolstation.dagger.desc=The Dagger is a short blade that can be thrown.\n\n특수능력:\n- 던지기\n\n데미지: 낮음\n내구도: 보통\n\n필요부품:\n- 나이프 날\n- 크로스바\n-손잡이 +gui.toolstation.fryingpan.desc=The Frying Pan is a heavy weapon that uses sheer weight to stun foes.\n\n특수능력: 블럭\n기본능력: 무거움\n쉬프트클릭: 땅에 놓기\n데미지: 낮음\n내구도: 높음\n\n필요부품:\n- 팬\n-손잡이 +gui.toolstation.battlesign.desc=The Battlesign is an advance in weapon technology worthy of Zombie Pigmen everywhere.\n\n특수능력:\n데미지 반사\n\n기본능력: 하양\n\n데미지: 낮음\n내구도: 높음 +gui.toolstation.chisel.desc=The Chisel is a utility tool that carves shapes into blocks.\n\n기본능력:\n- 제작용아이템\n특수능력: 정\n내구도: 높음\n\n필요부품:\n- 정 머리\n-손잡이 +gui.toolstation.shortbow.desc=The Shortbow is a ranged weapon. It fires arrows quickly and precisely at its foes.\n\n활시위 속도: 빠름\n\n필요부품:\n- 도구 막대기\n- 활실\n- 도구 막대기 +gui.toolstation.arrow.desc=Arrows are projectiles usually fired from bows.\n\n필요부품:\n- 화살머리\n- 도구 막대리\n- 깃털 +gui.toolstation.hammer.desc=The Hammer is a broad mining tool. It harvests blocks in a wide range and is effective against undead.\n\n기본효과:\n범위공격\n- (3x3)\n- 스마이트\n\n내구도: 높음 +gui.toolstation.lumberaxe.desc=The Lumber Axe is a broad chopping tool. It can fell entire trees or gather wood in a wide range.\n\n기본효과:\n범위공격\n- 챱트리\n- (3x3x3)\n\n내구도: 높음 +gui.toolstation.excavator.desc=The Excavator is a broad digging tool. It harvests soil and snow in a wide range.\n\n기본능력:\n- 범위공격\n- (3x3)\n\n내구도: 높음 +gui.toolstation.scythe.desc=The Scythe is a broad reaping tool. It is effective on plants and attacks enemies in a wide range.\n\n기본능력:\n범위능력\n- (3x3x3)\n\n내구도: 높음\n데미지: 낮음, AoE +gui.toolstation.cleaver.desc=The Cleaver is a heavy defensive weapon. It has powerful strikes, but is difficult to wield.\n\n특수능력: 블럭\n기본능력:\n- 참수\n\n데미지: 높음\n내구도: 높음 +gui.toolstation.battleaxe.desc=The Battleaxe is a heavy offensive weapon. It is capable of bringing down small trees and can send foes flying.\n\n특수능력: 블럭\n기본효과:\n- 밀치기\n- 광역효과\n- (1x9)\n\n데미지: 높음\n내구도: 높음 material.wood=나무 material.wood.display=나무 @@ -882,6 +881,6 @@ tool.arrow=화살 # Customization of default tool names based on tool and material +#tool.shovel.wood=Wooden Shovel -tool.kingslimeprefix=King Slime +tool.kingslimeprefix=킹 슬라임 # Specific localization like materials #tool.shovel.kingslime=Regret diff --git a/resources/assets/tinker/lang/zh_CN.lang b/resources/assets/tinker/lang/zh_CN.lang index b1781179..194da482 100644 --- a/resources/assets/tinker/lang/zh_CN.lang +++ b/resources/assets/tinker/lang/zh_CN.lang @@ -5,13 +5,13 @@ itemGroup.TConstructParts=匠魂|部件 itemGroup.TConstructEquipables=匠魂|装备 crafters.ToolStation=工具组装台 -crafters.ToolForge=工具装配站 +crafters.ToolForge=工具装配台 crafters.TinkerTable=工匠工作台 crafters.PartBuilder=部件加工台 crafters.PatternShaper=模具加工台 crafters.CraftingStation=合成站 inventory.PatternChest=模具箱 -crafters.Smeltery=冶炼厂 +crafters.Smeltery=冶炼炉 crafters.Frypan=煎锅 inventory.knapsack=背包 @@ -22,7 +22,7 @@ ToolStation.PatternShaper.name=模具加工台 ToolStation.CastingTable.name=浇铸台 tile.FurnaceSlab.name=半砖熔炉 -tile.ToolForge.name=工具组装台 +tile.ToolForge.name=工具装配台 tile.TinkerTable.name=工匠工作台 tile.Armor.DryingRack.name=晾干架 CraftedSoil.Slime.name=黏滑泥泞 @@ -193,34 +193,34 @@ item.tconstruct.Pattern.bowstring.name=弓弦模具 item.tconstruct.Pattern.fletching.name=箭羽模具 item.tconstruct.Pattern.arrowhead.name=箭头模具 -item.tconstruct.Pattern.blank_cast.name=空白铸形 -item.tconstruct.MetalPattern.rod.name=手柄铸形 -item.tconstruct.MetalPattern.pickaxe.name=镐头铸形 -item.tconstruct.MetalPattern.shovel.name=铲头铸形 -item.tconstruct.MetalPattern.axe.name=斧刃铸形 -item.tconstruct.MetalPattern.swordblade.name=剑刃铸形 -item.tconstruct.MetalPattern.largeguard.name=宽护手铸形 -item.tconstruct.MetalPattern.mediumguard.name=护手铸形 -item.tconstruct.MetalPattern.crossbar.name=十字柄铸形 -item.tconstruct.MetalPattern.binding.name=绑定结铸形 -item.tconstruct.MetalPattern.frypan.name=盘铸形 -item.tconstruct.MetalPattern.sign.name=牌板铸形 -item.tconstruct.MetalPattern.knifeblade.name=刀刃铸形 -item.tconstruct.MetalPattern.chisel.name=凿刃铸形 -item.tconstruct.MetalPattern.largerod.name=坚韧手柄铸形 -item.tconstruct.MetalPattern.toughbinding.name=坚韧绑定结铸形 -item.tconstruct.MetalPattern.largeplate.name=大板铸形 -item.tconstruct.MetalPattern.broadaxe.name=宽斧刃铸形 -item.tconstruct.MetalPattern.scythe.name=镰刀刀刃铸形 -item.tconstruct.MetalPattern.excavator.name=开掘铲头铸形 -item.tconstruct.MetalPattern.largeblade.name=宽剑刃铸形 -item.tconstruct.MetalPattern.hammerhead.name=锤头铸形 -item.tconstruct.MetalPattern.fullguard.name=大型护手铸形 -item.tconstruct.MetalPattern.bowstring.name=弓弦铸形 -item.tconstruct.MetalPattern.fletching.name=箭羽铸形 -item.tconstruct.MetalPattern.arrowhead.name=箭头铸形 -item.tconstruct.MetalPattern.ingot.name=锭铸形 -item.tconstruct.MetalPattern.gem.name=宝石铸形 +item.tconstruct.Pattern.blank_cast.name=空白铸模 +item.tconstruct.MetalPattern.rod.name=手柄铸模 +item.tconstruct.MetalPattern.pickaxe.name=镐头铸模 +item.tconstruct.MetalPattern.shovel.name=铲头铸模 +item.tconstruct.MetalPattern.axe.name=斧刃铸模 +item.tconstruct.MetalPattern.swordblade.name=剑刃铸模 +item.tconstruct.MetalPattern.largeguard.name=宽护手铸模 +item.tconstruct.MetalPattern.mediumguard.name=护手铸模 +item.tconstruct.MetalPattern.crossbar.name=十字柄铸模 +item.tconstruct.MetalPattern.binding.name=绑定结铸模 +item.tconstruct.MetalPattern.frypan.name=盘铸模 +item.tconstruct.MetalPattern.sign.name=牌板铸模 +item.tconstruct.MetalPattern.knifeblade.name=刀刃铸模 +item.tconstruct.MetalPattern.chisel.name=凿刃铸模 +item.tconstruct.MetalPattern.largerod.name=坚韧手柄铸模 +item.tconstruct.MetalPattern.toughbinding.name=坚韧绑定结铸模 +item.tconstruct.MetalPattern.largeplate.name=大板铸模 +item.tconstruct.MetalPattern.broadaxe.name=宽斧刃铸模 +item.tconstruct.MetalPattern.scythe.name=镰刀刀刃铸模 +item.tconstruct.MetalPattern.excavator.name=开掘铲头铸模 +item.tconstruct.MetalPattern.largeblade.name=宽剑刃铸模 +item.tconstruct.MetalPattern.hammerhead.name=锤头铸模 +item.tconstruct.MetalPattern.fullguard.name=大型护手铸模 +item.tconstruct.MetalPattern.bowstring.name=弓弦铸模 +item.tconstruct.MetalPattern.fletching.name=箭羽铸模 +item.tconstruct.MetalPattern.arrowhead.name=箭头铸模 +item.tconstruct.MetalPattern.ingot.name=锭铸模 +item.tconstruct.MetalPattern.gem.name=宝石铸模 item.tconstruct.Materials.PaperStack.name=纸叠 item.tconstruct.Materials.SlimeCrystal.name=史莱姆水晶 @@ -265,10 +265,10 @@ item.tconstruct.Materials.AluminumDust.name=铝粉 item.tconstruct.Materials.ManyullynDust.name=玛玉灵粉 item.tconstruct.Materials.AluBrassDust.name=铝黄铜粉 -item.tconstruct.ArmorPattern.helmet.name=头盔铸形 -item.tconstruct.ArmorPattern.chestplate.name=胸甲铸形 -item.tconstruct.ArmorPattern.leggings.name=护腿铸形 -item.tconstruct.ArmorPattern.boots.name=靴子铸形 +item.tconstruct.ArmorPattern.helmet.name=头盔铸模 +item.tconstruct.ArmorPattern.chestplate.name=胸甲铸模 +item.tconstruct.ArmorPattern.leggings.name=护腿铸模 +item.tconstruct.ArmorPattern.boots.name=靴子铸模 item.tconstruct.helmetWood.name=木头盔 item.tconstruct.chestplateWood.name=木胸甲 @@ -294,8 +294,8 @@ item.tconstruct.jerky.blood.name=凝固血滴 beginnertool.pickaxe=初始镐子 beginnertool.hatchet=初始手斧 -Smeltery.Controller.name=冶炼厂填料仓 -Smeltery.Drain.name=排液口 +Smeltery.Controller.name=冶炼炉控制器 +Smeltery.Drain.name=冶炼炉排液口 Smeltery.Brick.name=冶炼炉砖块 Smeltery.Stone.name=焦黑石头 Smeltery.Cobblestone.name=焦黑圆石 @@ -308,9 +308,9 @@ Smeltery.Brick.Creeper.name=雕琢焦黑石砖块 Smeltery.Channel.name=浇注道 block.slime.soil.dirt.name=史莱姆土 -LavaTank.Tank.name=冶炼槽 -LavaTank.Gague.name=冶炼炉玻璃 -LavaTank.Window.name=冶炼炉视窗 +LavaTank.Tank.name=焦黑储罐 +LavaTank.Gague.name=焦黑玻璃 +LavaTank.Window.name=焦黑视窗 tile.landmine.name=地雷 @@ -408,7 +408,7 @@ block.slime.congealed.purple.name=紫色凝固史莱姆块 item.tconstruct.storage.knapsack.name=背包 item.tconstruct.blankpattern.pattern.name=空白模具 -item.tconstruct.blankpattern.cast.name=空白铸形 +item.tconstruct.blankpattern.cast.name=空白铸模 item.tconstruct.Bowstring.string.name=弓弦 item.tconstruct.Bowstring.enchantedfabric.name=附魔弓弦 @@ -521,7 +521,7 @@ item.tconstruct.glove.name=鼹鼠手套 item.tconstruct.modifier.creative.name=创造工具强化槽 SearedBlock.Table.name=浇铸台 -SearedBlock.Faucet.name=浇注道 +SearedBlock.Faucet.name=浇注口 SearedBlock.Basin.name=铸造盆 entity.TConstruct.EdibleSlime.name=蓝色史莱姆 @@ -649,7 +649,7 @@ brick1.tooltip=造价略高 brick2.tooltip=相当贵重 brick3.tooltip=能够发出红石信号, 最多延伸 brick4.tooltip=4格远 -brick5.tooltip=弹性! +brick5.tooltip=弹起来! craftedsoil.slab1.tooltip=治愈不死生物 craftedsoil.slab2.tooltip=伤害不死生物 speedblock1.tooltip=踩着它健步如飞 @@ -660,7 +660,7 @@ manual1.tooltip=作者: Skyla manual2.tooltip=作者: Skyla manual3.tooltip=作者: Thruul M'gon searedtank1.tooltip=容纳 -searedtank2.tooltip=保存一切获得的流体 +searedtank2.tooltip=掉落时也能保存其中的流体 oreberries1.tooltip=甜甜铁 oreberries2.tooltip=纯净光泽 oreberries3.tooltip=金属的味道 @@ -681,15 +681,15 @@ landmine2.tooltip=生物, 玩家和红石触发 landmine3.tooltip=生物和玩家触发 landmine4.tooltip=仅限红石触发 landmine5.tooltip=触发对象: -goldenhead1.tooltip=有人说让我们吃了这个倒下的敌人 -goldenhead2.tooltip=的头颅来强化自己的血脉 +goldenhead1.tooltip=吃下这些被你所击倒的敌人 +goldenhead2.tooltip=的头颅能强化你的血脉 oreberrybush1.tooltip=甜甜铁 oreberrybush2.tooltip=纯净光泽 oreberrybush3.tooltip=金属的味道 oreberrybush4.tooltip=锡皮人 oreberrybush5.tooltip=白巧克力 oreberrybush6.tooltip=爬行者的味道 -barricade.tooltip=在一格中放置4个 +barricade.tooltip=最多可叠加4个 pattern1.tooltip=材料耗费: pattern2.tooltip=材料耗费: potionlauncher.tooltip=测试物品 @@ -726,8 +726,8 @@ gui.landmine=地雷 gui.partcrafter1=合成工具部件 gui.partcrafter2=锻造工具 gui.partcrafter3=将模具和材料放入左侧以开始制作部件. -gui.partcrafter4=材料基础耐久: -gui.partcrafter5=手柄耐久修正: +gui.partcrafter4=基础耐久: +gui.partcrafter5=手柄系数: gui.partcrafter6=采掘速度: gui.partcrafter7=采掘等级: gui.partcrafter8= 心 diff --git a/src/api/java/modwarriors/notenoughkeys/api/Api.java b/src/api/java/modwarriors/notenoughkeys/api/Api.java new file mode 100644 index 00000000..390d28a3 --- /dev/null +++ b/src/api/java/modwarriors/notenoughkeys/api/Api.java @@ -0,0 +1,40 @@ +package modwarriors.notenoughkeys.api; + +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * Center of the API. Main api methods can be found in this class. + * + * @author TheTemportalist + */ +@SideOnly(Side.CLIENT) +public class Api { + + /** + * Checks if NotEnoughKeys is loaded in the current environment + * + * @return 'true' if loaded + */ + public static boolean isLoaded() { + return Loader.isModLoaded("notenoughkeys"); + } + + /** + * Registers a mod's keys with NEK + * + * @param modname The NAME of the mod registering the key + * @param keyDecriptions A String[] (Array[String]) of the key descriptions. i.e. new String[]{"key.hotbar1"} + */ + public static void registerMod(String modname, String[] keyDecriptions) { + try { + Class.forName("modwarriors.notenoughkeys.keys.KeyHelper").getMethod( + "registerMod", String.class, String[].class + ).invoke(null, modname, keyDecriptions); + } catch (Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/api/java/modwarriors/notenoughkeys/api/KeyBindingPressedEvent.java b/src/api/java/modwarriors/notenoughkeys/api/KeyBindingPressedEvent.java new file mode 100644 index 00000000..d17b8089 --- /dev/null +++ b/src/api/java/modwarriors/notenoughkeys/api/KeyBindingPressedEvent.java @@ -0,0 +1,43 @@ +package modwarriors.notenoughkeys.api; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.settings.KeyBinding; + +/** + * Called when a keybinding is triggered with the passed with valid modifiers + * + * @author TheTemportalist + */ +@SideOnly(Side.CLIENT) +@Cancelable +public class KeyBindingPressedEvent extends Event { + + /** + * The KeyBinding being triggered + */ + public KeyBinding keyBinding = null; + /** + * Tells whether a modifier was required AND was down when triggered + */ + public boolean shiftRequired = false, ctrlRequired = false, altRequired = false; + + /** + * Called with the passed keyBinding and modifiers. + * Subscribe to this event so activate a keybinding when triggered. + * + * @param keyBinding The KeyBinding being triggered. Stores the key's description and keycode + * @param modifiers The modifiers (SHIFT, CTRL, ALT) that determine when a compatible key is pressed + */ + public KeyBindingPressedEvent(KeyBinding keyBinding, boolean[] modifiers) { + super(); + this.keyBinding = keyBinding; + this.shiftRequired = modifiers[0]; + this.ctrlRequired = modifiers[1]; + this.altRequired = modifiers[2]; + + } + +} diff --git a/src/api/java/modwarriors/notenoughkeys/api/package-info.java b/src/api/java/modwarriors/notenoughkeys/api/package-info.java new file mode 100644 index 00000000..d53b0008 --- /dev/null +++ b/src/api/java/modwarriors/notenoughkeys/api/package-info.java @@ -0,0 +1,5 @@ + +@API(owner = "Not Enough Keys", provides = "API_NEK", + apiVersion = "1.0.0") package modwarriors.notenoughkeys.api; + +import cpw.mods.fml.common.API; diff --git a/src/main/java/tconstruct/TConstruct.java b/src/main/java/tconstruct/TConstruct.java index 9cca54e1..776d0b70 100644 --- a/src/main/java/tconstruct/TConstruct.java +++ b/src/main/java/tconstruct/TConstruct.java @@ -1,17 +1,23 @@ package tconstruct; -import java.util.Map; -import java.util.Random; - +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.*; +import cpw.mods.fml.common.network.NetworkCheckHandler; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.VillagerRegistry; +import cpw.mods.fml.relauncher.Side; import mantle.pulsar.config.ForgeCFG; import mantle.pulsar.control.PulseManager; import net.minecraft.world.gen.structure.MapGenStructureIO; import net.minecraftforge.common.MinecraftForge; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import tconstruct.achievements.AchievementEvents; import tconstruct.achievements.TAchievements; import tconstruct.api.TConstructAPI; @@ -44,22 +50,10 @@ import tconstruct.util.network.PacketPipeline; import tconstruct.weaponry.TinkerWeaponry; import tconstruct.world.TinkerWorld; import tconstruct.world.gen.SlimeIslandGen; -import tconstruct.world.village.ComponentSmeltery; -import tconstruct.world.village.ComponentToolWorkshop; -import tconstruct.world.village.TVillageTrades; -import tconstruct.world.village.VillageSmelteryHandler; -import tconstruct.world.village.VillageToolStationHandler; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.Mod.Instance; -import cpw.mods.fml.common.SidedProxy; -import cpw.mods.fml.common.network.NetworkCheckHandler; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.common.registry.VillagerRegistry; -import cpw.mods.fml.relauncher.Side; +import tconstruct.world.village.*; + +import java.util.Map; +import java.util.Random; /** * TConstruct, the tool mod. Craft your tools with style, then modify until the diff --git a/src/main/java/tconstruct/armor/ArmorProxyClient.java b/src/main/java/tconstruct/armor/ArmorProxyClient.java index 8e8ac926..b7449179 100644 --- a/src/main/java/tconstruct/armor/ArmorProxyClient.java +++ b/src/main/java/tconstruct/armor/ArmorProxyClient.java @@ -1,34 +1,48 @@ package tconstruct.armor; -import com.google.common.collect.Lists; -import cpw.mods.fml.common.*; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import java.util.*; import mantle.lib.client.MantleClientRegistry; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.settings.*; -import net.minecraft.entity.*; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.IAttributeInstance; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.*; -import net.minecraft.item.*; -import net.minecraft.potion.*; -import net.minecraft.util.*; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.client.GuiIngameForge; -import net.minecraftforge.client.event.*; +import net.minecraftforge.client.event.FOVUpdateEvent; +import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; +import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.common.MinecraftForge; -import tconstruct.armor.gui.*; +import tconstruct.armor.gui.ArmorExtendedGui; +import tconstruct.armor.gui.KnapsackGui; import tconstruct.armor.items.TravelGear; -import tconstruct.armor.model.*; -import tconstruct.armor.player.*; -import tconstruct.client.*; -import tconstruct.client.tabs.*; +import tconstruct.armor.model.BeltModel; +import tconstruct.armor.model.BootBump; +import tconstruct.armor.model.HiddenPlayerModel; +import tconstruct.armor.model.WingModel; +import tconstruct.armor.player.ArmorExtended; +import tconstruct.armor.player.KnapsackInventory; +import tconstruct.client.ArmorControls; +import tconstruct.client.tabs.InventoryTabArmorExtended; +import tconstruct.client.tabs.InventoryTabKnapsack; +import tconstruct.client.tabs.InventoryTabVanilla; +import tconstruct.client.tabs.TabRegistry; import tconstruct.common.TProxyCommon; import tconstruct.library.accessory.IAccessoryModel; import tconstruct.library.client.TConstructClientRegistry; @@ -36,476 +50,478 @@ import tconstruct.library.crafting.ModifyBuilder; import tconstruct.tools.TinkerTools; import tconstruct.world.TinkerWorld; -public class ArmorProxyClient extends ArmorProxyCommon -{ - public static WingModel wings = new WingModel(); - public static BootBump bootbump = new BootBump(); - public static HiddenPlayerModel glove = new HiddenPlayerModel(0.25F, 4); - public static HiddenPlayerModel vest = new HiddenPlayerModel(0.25f, 1); - public static BeltModel belt = new BeltModel(); +import java.util.Random; - public static KnapsackInventory knapsack = new KnapsackInventory(); - public static ArmorExtended armorExtended = new ArmorExtended(); +public class ArmorProxyClient extends ArmorProxyCommon { + public static WingModel wings = new WingModel(); + public static BootBump bootbump = new BootBump(); + public static HiddenPlayerModel glove = new HiddenPlayerModel(0.25F, 4); + public static HiddenPlayerModel vest = new HiddenPlayerModel(0.25f, 1); + public static BeltModel belt = new BeltModel(); - @Override - public void preInit() { - controlInstance = new ArmorControls(); - FMLCommonHandler.instance().bus().register(controlInstance); - MinecraftForge.EVENT_BUS.register(new TabRegistry()); - } + public static KnapsackInventory knapsack = new KnapsackInventory(); + public static ArmorExtended armorExtended = new ArmorExtended(); - @Override - public void initialize () - { - registerGuiHandler(); - registerKeys(); - registerManualIcons(); - registerManualRecipes(); - MinecraftForge.EVENT_BUS.register(this); - FMLCommonHandler.instance().bus().register(new ArmorAbilitiesClient(mc, controlInstance)); - } + @Override + public void preInit() { + controlInstance = new ArmorControls(); + FMLCommonHandler.instance().bus().register(controlInstance); + MinecraftForge.EVENT_BUS.register(controlInstance); + MinecraftForge.EVENT_BUS.register(new TabRegistry()); + } - private void registerManualIcons () - { - MantleClientRegistry.registerManualIcon("travelgoggles", TinkerArmor.travelGoggles.getDefaultItem()); - MantleClientRegistry.registerManualIcon("travelvest", TinkerArmor.travelVest.getDefaultItem()); - MantleClientRegistry.registerManualIcon("travelwings", TinkerArmor.travelWings.getDefaultItem()); - MantleClientRegistry.registerManualIcon("travelboots", TinkerArmor.travelBoots.getDefaultItem()); - MantleClientRegistry.registerManualIcon("travelbelt", TinkerArmor.travelBelt.getDefaultItem()); - MantleClientRegistry.registerManualIcon("travelglove", TinkerArmor.travelGlove.getDefaultItem()); - } + @Override + public void initialize() { + registerGuiHandler(); + registerKeys(); + registerManualIcons(); + registerManualRecipes(); + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(new ArmorAbilitiesClient(mc, controlInstance)); + } - private void registerManualRecipes () - { - ItemStack feather = new ItemStack(Items.feather); - ItemStack redstone = new ItemStack(Items.redstone); - ItemStack goggles = TinkerArmor.travelGoggles.getDefaultItem(); + private void registerManualIcons() { + MantleClientRegistry + .registerManualIcon("travelgoggles", TinkerArmor.travelGoggles.getDefaultItem()); + MantleClientRegistry + .registerManualIcon("travelvest", TinkerArmor.travelVest.getDefaultItem()); + MantleClientRegistry + .registerManualIcon("travelwings", TinkerArmor.travelWings.getDefaultItem()); + MantleClientRegistry + .registerManualIcon("travelboots", TinkerArmor.travelBoots.getDefaultItem()); + MantleClientRegistry + .registerManualIcon("travelbelt", TinkerArmor.travelBelt.getDefaultItem()); + MantleClientRegistry + .registerManualIcon("travelglove", TinkerArmor.travelGlove.getDefaultItem()); + } - TConstructClientRegistry.registerManualModifier("nightvision", goggles.copy(), new ItemStack(Items.flint_and_steel), new ItemStack(Items.potionitem, 1, 8198), new ItemStack(Items.golden_carrot), null); + private void registerManualRecipes() { + ItemStack feather = new ItemStack(Items.feather); + ItemStack redstone = new ItemStack(Items.redstone); + ItemStack goggles = TinkerArmor.travelGoggles.getDefaultItem(); - ItemStack vest = TinkerArmor.travelVest.getDefaultItem(); - TConstructClientRegistry.registerManualModifier("dodge", vest.copy(), new ItemStack(Items.ender_eye), new ItemStack(Items.ender_pearl), new ItemStack(Items.sugar), null); - TConstructClientRegistry.registerManualModifier("stealth", vest.copy(), new ItemStack(Items.fermented_spider_eye), new ItemStack(Items.ender_eye), new ItemStack(Items.potionitem, 1, 8206), new ItemStack(Items.golden_carrot)); + TConstructClientRegistry.registerManualModifier("nightvision", goggles.copy(), + new ItemStack(Items.flint_and_steel), new ItemStack(Items.potionitem, 1, 8198), + new ItemStack(Items.golden_carrot), null); - ItemStack wings = TinkerArmor.travelWings.getDefaultItem(); - TConstructClientRegistry.registerManualModifier("doublejumpwings", wings.copy(), new ItemStack(Items.ghast_tear), new ItemStack(TinkerWorld.slimeGel, 1, 0), new ItemStack(Blocks.piston), null); + ItemStack vest = TinkerArmor.travelVest.getDefaultItem(); + TConstructClientRegistry + .registerManualModifier("dodge", vest.copy(), new ItemStack(Items.ender_eye), + new ItemStack(Items.ender_pearl), new ItemStack(Items.sugar), null); + TConstructClientRegistry.registerManualModifier("stealth", vest.copy(), + new ItemStack(Items.fermented_spider_eye), new ItemStack(Items.ender_eye), + new ItemStack(Items.potionitem, 1, 8206), new ItemStack(Items.golden_carrot)); - ItemStack[] recipe = new ItemStack[] { new ItemStack(TinkerWorld.slimeGel, 1, 0), new ItemStack(Items.ender_pearl), feather, feather, feather, feather, feather, feather }; - ItemStack modWings = ModifyBuilder.instance.modifyItem(wings, recipe); - MantleClientRegistry.registerManualLargeRecipe("featherfall", modWings.copy(), feather, new ItemStack(TinkerWorld.slimeGel, 1, 0), feather, feather, wings.copy(), feather, feather, new ItemStack(Items.ender_pearl), feather); + ItemStack wings = TinkerArmor.travelWings.getDefaultItem(); + TConstructClientRegistry.registerManualModifier("doublejumpwings", wings.copy(), + new ItemStack(Items.ghast_tear), new ItemStack(TinkerWorld.slimeGel, 1, 0), + new ItemStack(Blocks.piston), null); - ItemStack boots = TinkerArmor.travelBoots.getDefaultItem(); - TConstructClientRegistry.registerManualModifier("doublejumpboots", boots.copy(), new ItemStack(Items.ghast_tear), new ItemStack(TinkerWorld.slimeGel, 1, 1), new ItemStack(Blocks.piston), null); - TConstructClientRegistry.registerManualModifier("waterwalk", boots.copy(), new ItemStack(Blocks.waterlily), new ItemStack(Blocks.waterlily)); - TConstructClientRegistry.registerManualModifier("leadboots", boots.copy(), new ItemStack(Blocks.iron_block)); - TConstructClientRegistry.registerManualModifier("slimysoles", boots.copy(), new ItemStack(TinkerWorld.slimePad, 1, 0), new ItemStack(TinkerWorld.slimePad, 1, 0)); + ItemStack[] recipe = new ItemStack[] { new ItemStack(TinkerWorld.slimeGel, 1, 0), + new ItemStack(Items.ender_pearl), feather, feather, feather, feather, feather, + feather + }; + ItemStack modWings = ModifyBuilder.instance.modifyItem(wings, recipe); + MantleClientRegistry.registerManualLargeRecipe("featherfall", modWings.copy(), feather, + new ItemStack(TinkerWorld.slimeGel, 1, 0), feather, feather, wings.copy(), feather, + feather, new ItemStack(Items.ender_pearl), feather); - ItemStack gloves = TinkerArmor.travelGlove.getDefaultItem(); - TConstructClientRegistry.registerManualModifier("glovehaste", gloves.copy(), redstone, new ItemStack(Blocks.redstone_block)); - //MantleClientRegistry.registerManualSmallRecipe("gloveclimb", gloves.copy(), new ItemStack(Items.slime_ball), new ItemStack(Blocks.web), new ItemStack(TinkerTools.materials, 1, 25), null); - TConstructClientRegistry.registerManualModifier("gloveknuckles", gloves.copy(), new ItemStack(Items.quartz), new ItemStack(Blocks.quartz_block, 1, Short.MAX_VALUE)); + ItemStack boots = TinkerArmor.travelBoots.getDefaultItem(); + TConstructClientRegistry.registerManualModifier("doublejumpboots", boots.copy(), + new ItemStack(Items.ghast_tear), new ItemStack(TinkerWorld.slimeGel, 1, 1), + new ItemStack(Blocks.piston), null); + TConstructClientRegistry + .registerManualModifier("waterwalk", boots.copy(), new ItemStack(Blocks.waterlily), + new ItemStack(Blocks.waterlily)); + TConstructClientRegistry.registerManualModifier("leadboots", boots.copy(), + new ItemStack(Blocks.iron_block)); + TConstructClientRegistry.registerManualModifier("slimysoles", boots.copy(), + new ItemStack(TinkerWorld.slimePad, 1, 0), + new ItemStack(TinkerWorld.slimePad, 1, 0)); - // moss - ItemStack moss = new ItemStack(TinkerTools.materials, 1, 6); - TConstructClientRegistry.registerManualModifier("mossgoggles", goggles.copy(), moss.copy()); - TConstructClientRegistry.registerManualModifier("mossvest", vest.copy(), moss.copy()); - TConstructClientRegistry.registerManualModifier("mosswings", wings.copy(), moss.copy()); - TConstructClientRegistry.registerManualModifier("mossboots", boots.copy(), moss.copy()); - } + ItemStack gloves = TinkerArmor.travelGlove.getDefaultItem(); + TConstructClientRegistry.registerManualModifier("glovehaste", gloves.copy(), redstone, + new ItemStack(Blocks.redstone_block)); + //MantleClientRegistry.registerManualSmallRecipe("gloveclimb", gloves.copy(), new ItemStack(Items.slime_ball), new ItemStack(Blocks.web), new ItemStack(TinkerTools.materials, 1, 25), null); + TConstructClientRegistry + .registerManualModifier("gloveknuckles", gloves.copy(), new ItemStack(Items.quartz), + new ItemStack(Blocks.quartz_block, 1, Short.MAX_VALUE)); - @Override - protected void registerGuiHandler () - { - super.registerGuiHandler(); - TProxyCommon.registerClientGuiHandler(inventoryGui, this); - TProxyCommon.registerClientGuiHandler(armorGuiID, this); - TProxyCommon.registerClientGuiHandler(knapsackGuiID, this); - } + // moss + ItemStack moss = new ItemStack(TinkerTools.materials, 1, 6); + TConstructClientRegistry.registerManualModifier("mossgoggles", goggles.copy(), moss.copy()); + TConstructClientRegistry.registerManualModifier("mossvest", vest.copy(), moss.copy()); + TConstructClientRegistry.registerManualModifier("mosswings", wings.copy(), moss.copy()); + TConstructClientRegistry.registerManualModifier("mossboots", boots.copy(), moss.copy()); + } - @Override - public Object getClientGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z) - { - if (ID == ArmorProxyCommon.inventoryGui) - { - GuiInventory inventory = new GuiInventory(player); - return inventory; - } - if (ID == ArmorProxyCommon.armorGuiID) - { - ArmorProxyClient.armorExtended.init(Minecraft.getMinecraft().thePlayer); - return new ArmorExtendedGui(player.inventory, ArmorProxyClient.armorExtended); - } - if (ID == ArmorProxyCommon.knapsackGuiID) - { - ArmorProxyClient.knapsack.init(Minecraft.getMinecraft().thePlayer); - return new KnapsackGui(player.inventory, ArmorProxyClient.knapsack); - } - return null; - } + @Override + protected void registerGuiHandler() { + super.registerGuiHandler(); + TProxyCommon.registerClientGuiHandler(inventoryGui, this); + TProxyCommon.registerClientGuiHandler(armorGuiID, this); + TProxyCommon.registerClientGuiHandler(knapsackGuiID, this); + } - @Override - public void registerTickHandler () - { - FMLCommonHandler.instance().bus().register(new ArmorTickHandler()); - } + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, + int z) { + if (ID == ArmorProxyCommon.inventoryGui) { + GuiInventory inventory = new GuiInventory(player); + return inventory; + } + if (ID == ArmorProxyCommon.armorGuiID) { + ArmorProxyClient.armorExtended.init(Minecraft.getMinecraft().thePlayer); + return new ArmorExtendedGui(player.inventory, ArmorProxyClient.armorExtended); + } + if (ID == ArmorProxyCommon.knapsackGuiID) { + ArmorProxyClient.knapsack.init(Minecraft.getMinecraft().thePlayer); + return new KnapsackGui(player.inventory, ArmorProxyClient.knapsack); + } + return null; + } - /* Keybindings */ - public static ArmorControls controlInstance; + @Override + public void registerTickHandler() { + FMLCommonHandler.instance().bus().register(new ArmorTickHandler()); + } - @Override - public void registerKeys () - { - uploadKeyBindingsToGame(Minecraft.getMinecraft().gameSettings, controlInstance); + /* Keybindings */ + public static ArmorControls controlInstance; - TabRegistry.registerTab(new InventoryTabVanilla()); - TabRegistry.registerTab(new InventoryTabArmorExtended()); - TabRegistry.registerTab(new InventoryTabKnapsack()); - } + @Override + public void registerKeys() { + controlInstance.registerKeys(); - public void uploadKeyBindingsToGame (GameSettings settings, TKeyHandler keyhandler) - { - ArrayList harvestedBindings = Lists.newArrayList(); - for (KeyBinding kb : keyhandler.keyBindings) - { - harvestedBindings.add(kb); - } + TabRegistry.registerTab(new InventoryTabVanilla()); + TabRegistry.registerTab(new InventoryTabArmorExtended()); + TabRegistry.registerTab(new InventoryTabKnapsack()); + } - KeyBinding[] modKeyBindings = harvestedBindings.toArray(new KeyBinding[harvestedBindings.size()]); - KeyBinding[] allKeys = new KeyBinding[settings.keyBindings.length + modKeyBindings.length]; - System.arraycopy(settings.keyBindings, 0, allKeys, 0, settings.keyBindings.length); - System.arraycopy(modKeyBindings, 0, allKeys, settings.keyBindings.length, modKeyBindings.length); - settings.keyBindings = allKeys; - settings.loadOptions(); - } + Minecraft mc = Minecraft.getMinecraft(); - Minecraft mc = Minecraft.getMinecraft(); + private static final ResourceLocation hearts = new ResourceLocation("tinker", + "textures/gui/newhearts.png"); + private static final ResourceLocation icons = new ResourceLocation("textures/gui/icons.png"); + // public static int left_height = 39; + // public static int right_height = 39; + Random rand = new Random(); + int updateCounter = 0; - private static final ResourceLocation hearts = new ResourceLocation("tinker", "textures/gui/newhearts.png"); - private static final ResourceLocation icons = new ResourceLocation("textures/gui/icons.png"); - // public static int left_height = 39; - // public static int right_height = 39; - Random rand = new Random(); - int updateCounter = 0; + GameSettings gs = Minecraft.getMinecraft().gameSettings; - GameSettings gs = Minecraft.getMinecraft().gameSettings; + @SubscribeEvent + public void goggleZoom(FOVUpdateEvent event) { + if (ArmorControls.zoom) { + ItemStack helmet = event.entity.getCurrentArmor(3); + if (helmet != null && helmet.getItem() instanceof TravelGear) { + event.newfov = 0.3f; + } + } + //ItemStack feet = player.getCurrentArmor(0); + //event.newfov = 1.0f; + } - @SubscribeEvent - public void goggleZoom (FOVUpdateEvent event) - { - if (ArmorControls.zoom) - { - ItemStack helmet = event.entity.getCurrentArmor(3); - if (helmet != null && helmet.getItem() instanceof TravelGear) - { - event.newfov = 0.3f; - } - } - //ItemStack feet = player.getCurrentArmor(0); - //event.newfov = 1.0f; - } + /* HUD */ + @SubscribeEvent + public void renderHealthbar(RenderGameOverlayEvent.Pre event) { + if (Loader.isModLoaded( + "rpghud")) // uses different display, displays health correctly by itself. + return; - /* HUD */ - @SubscribeEvent - public void renderHealthbar (RenderGameOverlayEvent.Pre event) - { - if(Loader.isModLoaded("rpghud")) // uses different display, displays health correctly by itself. - return; + if (!Loader.isModLoaded("tukmc_Vz") || Loader + .isModLoaded("borderlands"))// Loader check to avoid conflicting + // with a GUI mod (thanks Vazkii!) + { + if (event.type == ElementType.HEALTH) { + updateCounter++; - if (!Loader.isModLoaded("tukmc_Vz") || Loader.isModLoaded("borderlands"))// Loader check to avoid conflicting - // with a GUI mod (thanks Vazkii!) - { - if (event.type == ElementType.HEALTH) - { - updateCounter++; + ScaledResolution scaledresolution = new ScaledResolution(this.mc, + this.mc.displayWidth, this.mc.displayHeight); + int scaledWidth = scaledresolution.getScaledWidth(); + int scaledHeight = scaledresolution.getScaledHeight(); + int xBasePos = scaledWidth / 2 - 91; + int yBasePos = scaledHeight - 39; - ScaledResolution scaledresolution = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); - int scaledWidth = scaledresolution.getScaledWidth(); - int scaledHeight = scaledresolution.getScaledHeight(); - int xBasePos = scaledWidth / 2 - 91; - int yBasePos = scaledHeight - 39; + boolean highlight = mc.thePlayer.hurtResistantTime / 3 % 2 == 1; - boolean highlight = mc.thePlayer.hurtResistantTime / 3 % 2 == 1; + if (mc.thePlayer.hurtResistantTime < 10) { + highlight = false; + } - if (mc.thePlayer.hurtResistantTime < 10) - { - highlight = false; - } + IAttributeInstance attrMaxHealth = this.mc.thePlayer + .getEntityAttribute(SharedMonsterAttributes.maxHealth); + int health = MathHelper.ceiling_float_int(mc.thePlayer.getHealth()); + int healthLast = MathHelper.ceiling_float_int(mc.thePlayer.prevHealth); + float healthMax = (float) attrMaxHealth.getAttributeValue(); + if (healthMax > 20) + healthMax = 20; + float absorb = this.mc.thePlayer.getAbsorptionAmount(); - IAttributeInstance attrMaxHealth = this.mc.thePlayer.getEntityAttribute(SharedMonsterAttributes.maxHealth); - int health = MathHelper.ceiling_float_int(mc.thePlayer.getHealth()); - int healthLast = MathHelper.ceiling_float_int(mc.thePlayer.prevHealth); - float healthMax = (float) attrMaxHealth.getAttributeValue(); - if (healthMax > 20) - healthMax = 20; - float absorb = this.mc.thePlayer.getAbsorptionAmount(); + int healthRows = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F / 10.0F); + int rowHeight = Math.max(10 - (healthRows - 2), 3); - int healthRows = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F / 10.0F); - int rowHeight = Math.max(10 - (healthRows - 2), 3); + this.rand.setSeed((long) (updateCounter * 312871)); - this.rand.setSeed((long) (updateCounter * 312871)); + int left = scaledWidth / 2 - 91; + int top = scaledHeight - GuiIngameForge.left_height; - int left = scaledWidth / 2 - 91; - int top = scaledHeight - GuiIngameForge.left_height; + if (!GuiIngameForge.renderExperiance) { + top += 7; + yBasePos += 7; + } - if (!GuiIngameForge.renderExperiance) - { - top += 7; - yBasePos += 7; - } + int regen = -1; + if (mc.thePlayer.isPotionActive(Potion.regeneration)) { + regen = updateCounter % 25; + } - int regen = -1; - if (mc.thePlayer.isPotionActive(Potion.regeneration)) - { - regen = updateCounter % 25; - } + final int TOP = 9 * (mc.theWorld.getWorldInfo().isHardcoreModeEnabled() ? 5 : 0); + final int BACKGROUND = (highlight ? 25 : 16); + int MARGIN = 16; + if (mc.thePlayer.isPotionActive(Potion.poison)) + MARGIN += 36; + else if (mc.thePlayer.isPotionActive(Potion.wither)) + MARGIN += 72; + float absorbRemaining = absorb; - final int TOP = 9 * (mc.theWorld.getWorldInfo().isHardcoreModeEnabled() ? 5 : 0); - final int BACKGROUND = (highlight ? 25 : 16); - int MARGIN = 16; - if (mc.thePlayer.isPotionActive(Potion.poison)) - MARGIN += 36; - else if (mc.thePlayer.isPotionActive(Potion.wither)) - MARGIN += 72; - float absorbRemaining = absorb; + for (int i = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F) - 1; + i >= 0; --i) { + int b0 = (highlight ? 1 : 0); + int row = MathHelper.ceiling_float_int((float) (i + 1) / 10.0F) - 1; + int x = left + i % 10 * 8; + int y = top - row * rowHeight; - for (int i = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F) - 1; i >= 0; --i) - { - int b0 = (highlight ? 1 : 0); - int row = MathHelper.ceiling_float_int((float) (i + 1) / 10.0F) - 1; - int x = left + i % 10 * 8; - int y = top - row * rowHeight; + if (health <= 4) + y += rand.nextInt(2); + if (i == regen) + y -= 2; - if (health <= 4) - y += rand.nextInt(2); - if (i == regen) - y -= 2; + drawTexturedModalRect(x, y, BACKGROUND, TOP, 9, 9); - drawTexturedModalRect(x, y, BACKGROUND, TOP, 9, 9); + if (highlight) { + if (i * 2 + 1 < healthLast) + drawTexturedModalRect(x, y, MARGIN + 54, TOP, 9, 9); // 6 + else if (i * 2 + 1 == healthLast) + drawTexturedModalRect(x, y, MARGIN + 63, TOP, 9, 9); // 7 + } - if (highlight) - { - if (i * 2 + 1 < healthLast) - drawTexturedModalRect(x, y, MARGIN + 54, TOP, 9, 9); // 6 - else if (i * 2 + 1 == healthLast) - drawTexturedModalRect(x, y, MARGIN + 63, TOP, 9, 9); // 7 - } + if (absorbRemaining > 0.0F) { + if (absorbRemaining == absorb && absorb % 2.0F == 1.0F) + drawTexturedModalRect(x, y, MARGIN + 153, TOP, 9, 9); // 17 + else + drawTexturedModalRect(x, y, MARGIN + 144, TOP, 9, 9); // 16 + absorbRemaining -= 2.0F; + } + else { + if (i * 2 + 1 < health) + drawTexturedModalRect(x, y, MARGIN + 36, TOP, 9, 9); // 4 + else if (i * 2 + 1 == health) + drawTexturedModalRect(x, y, MARGIN + 45, TOP, 9, 9); // 5 + } + } - if (absorbRemaining > 0.0F) - { - if (absorbRemaining == absorb && absorb % 2.0F == 1.0F) - drawTexturedModalRect(x, y, MARGIN + 153, TOP, 9, 9); // 17 - else - drawTexturedModalRect(x, y, MARGIN + 144, TOP, 9, 9); // 16 - absorbRemaining -= 2.0F; - } - else - { - if (i * 2 + 1 < health) - drawTexturedModalRect(x, y, MARGIN + 36, TOP, 9, 9); // 4 - else if (i * 2 + 1 == health) - drawTexturedModalRect(x, y, MARGIN + 45, TOP, 9, 9); // 5 - } - } - - int potionOffset = 0; - PotionEffect potion = mc.thePlayer.getActivePotionEffect(Potion.wither); - if (potion != null) - potionOffset = 18; - potion = mc.thePlayer.getActivePotionEffect(Potion.poison); - if (potion != null) - potionOffset = 9; + int potionOffset = 0; + PotionEffect potion = mc.thePlayer.getActivePotionEffect(Potion.wither); + if (potion != null) + potionOffset = 18; + potion = mc.thePlayer.getActivePotionEffect(Potion.poison); + if (potion != null) + potionOffset = 9; if (mc.theWorld.getWorldInfo().isHardcoreModeEnabled()) potionOffset += 27; - // Extra hearts - this.mc.getTextureManager().bindTexture(hearts); + // Extra hearts + this.mc.getTextureManager().bindTexture(hearts); - int hp = MathHelper.ceiling_float_int(this.mc.thePlayer.getHealth()); - for (int iter = 0; iter < hp / 20; iter++) - { - int renderHearts = (hp - 20 * (iter + 1)) / 2; - if (renderHearts > 10) - renderHearts = 10; - for (int i = 0; i < renderHearts; i++) - { - int y = 0; - if (i == regen) - y -= 2; - this.drawTexturedModalRect(xBasePos + 8 * i, yBasePos + y, 0 + 18 * iter, potionOffset, 9, 9); - } - if (hp % 2 == 1 && renderHearts < 10) - { - this.drawTexturedModalRect(xBasePos + 8 * renderHearts, yBasePos, 9 + 18 * iter, potionOffset, 9, 9); - } - } + int hp = MathHelper.ceiling_float_int(this.mc.thePlayer.getHealth()); + for (int iter = 0; iter < hp / 20; iter++) { + int renderHearts = (hp - 20 * (iter + 1)) / 2; + if (renderHearts > 10) + renderHearts = 10; + for (int i = 0; i < renderHearts; i++) { + int y = 0; + if (i == regen) + y -= 2; + this.drawTexturedModalRect(xBasePos + 8 * i, yBasePos + y, 0 + 18 * iter, + potionOffset, 9, 9); + } + if (hp % 2 == 1 && renderHearts < 10) { + this.drawTexturedModalRect(xBasePos + 8 * renderHearts, yBasePos, + 9 + 18 * iter, potionOffset, 9, 9); + } + } - this.mc.getTextureManager().bindTexture(icons); - GuiIngameForge.left_height += 10; - if (absorb > 0) - GuiIngameForge.left_height += 10; + this.mc.getTextureManager().bindTexture(icons); + GuiIngameForge.left_height += 10; + if (absorb > 0) + GuiIngameForge.left_height += 10; - event.setCanceled(true); - if (event.type == ElementType.CROSSHAIRS && gs.thirdPersonView != 0) - { - event.setCanceled(true); - } - } - } - } + event.setCanceled(true); + if (event.type == ElementType.CROSSHAIRS && gs.thirdPersonView != 0) { + event.setCanceled(true); + } + } + } + } - public void drawTexturedModalRect (int par1, int par2, int par3, int par4, int par5, int par6) - { - float f = 0.00390625F; - float f1 = 0.00390625F; - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + par6), (double) this.zLevel, (double) ((float) (par3 + 0) * f), (double) ((float) (par4 + par6) * f1)); - tessellator.addVertexWithUV((double) (par1 + par5), (double) (par2 + par6), (double) this.zLevel, (double) ((float) (par3 + par5) * f), (double) ((float) (par4 + par6) * f1)); - tessellator.addVertexWithUV((double) (par1 + par5), (double) (par2 + 0), (double) this.zLevel, (double) ((float) (par3 + par5) * f), (double) ((float) (par4 + 0) * f1)); - tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, (double) ((float) (par3 + 0) * f), (double) ((float) (par4 + 0) * f1)); - tessellator.draw(); - } + public void drawTexturedModalRect(int par1, int par2, int par3, int par4, int par5, int par6) { + float f = 0.00390625F; + float f1 = 0.00390625F; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator + .addVertexWithUV((double) (par1 + 0), (double) (par2 + par6), (double) this.zLevel, + (double) ((float) (par3 + 0) * f), (double) ((float) (par4 + par6) * f1)); + tessellator.addVertexWithUV((double) (par1 + par5), (double) (par2 + par6), + (double) this.zLevel, (double) ((float) (par3 + par5) * f), + (double) ((float) (par4 + par6) * f1)); + tessellator + .addVertexWithUV((double) (par1 + par5), (double) (par2 + 0), (double) this.zLevel, + (double) ((float) (par3 + par5) * f), (double) ((float) (par4 + 0) * f1)); + tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, + (double) ((float) (par3 + 0) * f), (double) ((float) (par4 + 0) * f1)); + tessellator.draw(); + } - double zLevel = 0; + double zLevel = 0; - /* Armor rendering */ - @SubscribeEvent - public void adjustArmor (RenderPlayerEvent.SetArmorModel event) - { - switch (event.slot) - { - case 1: - ArmorProxyClient.vest.onGround = event.renderer.modelBipedMain.onGround; - ArmorProxyClient.vest.isRiding = event.renderer.modelBipedMain.isRiding; - ArmorProxyClient.vest.isChild = event.renderer.modelBipedMain.isChild; - ArmorProxyClient.vest.isSneak = event.renderer.modelBipedMain.isSneak; - case 2: - ArmorProxyClient.wings.onGround = event.renderer.modelBipedMain.onGround; - ArmorProxyClient.wings.isRiding = event.renderer.modelBipedMain.isRiding; - ArmorProxyClient.wings.isChild = event.renderer.modelBipedMain.isChild; - ArmorProxyClient.wings.isSneak = event.renderer.modelBipedMain.isSneak; + /* Armor rendering */ + @SubscribeEvent + public void adjustArmor(RenderPlayerEvent.SetArmorModel event) { + switch (event.slot) { + case 1: + ArmorProxyClient.vest.onGround = event.renderer.modelBipedMain.onGround; + ArmorProxyClient.vest.isRiding = event.renderer.modelBipedMain.isRiding; + ArmorProxyClient.vest.isChild = event.renderer.modelBipedMain.isChild; + ArmorProxyClient.vest.isSneak = event.renderer.modelBipedMain.isSneak; + case 2: + ArmorProxyClient.wings.onGround = event.renderer.modelBipedMain.onGround; + ArmorProxyClient.wings.isRiding = event.renderer.modelBipedMain.isRiding; + ArmorProxyClient.wings.isChild = event.renderer.modelBipedMain.isChild; + ArmorProxyClient.wings.isSneak = event.renderer.modelBipedMain.isSneak; - ArmorProxyClient.glove.onGround = event.renderer.modelBipedMain.onGround; - ArmorProxyClient.glove.isRiding = event.renderer.modelBipedMain.isRiding; - ArmorProxyClient.glove.isChild = event.renderer.modelBipedMain.isChild; - ArmorProxyClient.glove.isSneak = event.renderer.modelBipedMain.isSneak; - ArmorProxyClient.glove.heldItemLeft = event.renderer.modelBipedMain.heldItemLeft; - ArmorProxyClient.glove.heldItemRight = event.renderer.modelBipedMain.heldItemRight; + ArmorProxyClient.glove.onGround = event.renderer.modelBipedMain.onGround; + ArmorProxyClient.glove.isRiding = event.renderer.modelBipedMain.isRiding; + ArmorProxyClient.glove.isChild = event.renderer.modelBipedMain.isChild; + ArmorProxyClient.glove.isSneak = event.renderer.modelBipedMain.isSneak; + ArmorProxyClient.glove.heldItemLeft = event.renderer.modelBipedMain.heldItemLeft; + ArmorProxyClient.glove.heldItemRight = event.renderer.modelBipedMain.heldItemRight; - ArmorProxyClient.belt.onGround = event.renderer.modelBipedMain.onGround; - ArmorProxyClient.belt.isRiding = event.renderer.modelBipedMain.isRiding; - ArmorProxyClient.belt.isChild = event.renderer.modelBipedMain.isChild; - ArmorProxyClient.belt.isSneak = event.renderer.modelBipedMain.isSneak; + ArmorProxyClient.belt.onGround = event.renderer.modelBipedMain.onGround; + ArmorProxyClient.belt.isRiding = event.renderer.modelBipedMain.isRiding; + ArmorProxyClient.belt.isChild = event.renderer.modelBipedMain.isChild; + ArmorProxyClient.belt.isSneak = event.renderer.modelBipedMain.isSneak; - renderArmorExtras(event); + renderArmorExtras(event); - break; - case 3: - ArmorProxyClient.bootbump.onGround = event.renderer.modelBipedMain.onGround; - ArmorProxyClient.bootbump.isRiding = event.renderer.modelBipedMain.isRiding; - ArmorProxyClient.bootbump.isChild = event.renderer.modelBipedMain.isChild; - ArmorProxyClient.bootbump.isSneak = event.renderer.modelBipedMain.isSneak; - break; - } - } + break; + case 3: + ArmorProxyClient.bootbump.onGround = event.renderer.modelBipedMain.onGround; + ArmorProxyClient.bootbump.isRiding = event.renderer.modelBipedMain.isRiding; + ArmorProxyClient.bootbump.isChild = event.renderer.modelBipedMain.isChild; + ArmorProxyClient.bootbump.isSneak = event.renderer.modelBipedMain.isSneak; + break; + } + } - void renderArmorExtras (RenderPlayerEvent.SetArmorModel event) - { - float partialTick = event.partialRenderTick; + void renderArmorExtras(RenderPlayerEvent.SetArmorModel event) { + float partialTick = event.partialRenderTick; - EntityPlayer player = event.entityPlayer; + EntityPlayer player = event.entityPlayer; - // todo: synchronize extra armor with other clients. Until then, only draw locally - if(player != Minecraft.getMinecraft().thePlayer) - return; + // todo: synchronize extra armor with other clients. Until then, only draw locally + if (player != Minecraft.getMinecraft().thePlayer) + return; + float posX = (float) (player.lastTickPosX + + (player.posX - player.lastTickPosX) * partialTick); + float posY = (float) (player.lastTickPosY + + (player.posY - player.lastTickPosY) * partialTick); + float posZ = (float) (player.lastTickPosZ + + (player.posZ - player.lastTickPosZ) * partialTick); - float posX = (float) (player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTick); - float posY = (float) (player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTick); - float posZ = (float) (player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTick); + float yawOffset = this + .interpolateRotation(player.prevRenderYawOffset, player.renderYawOffset, + partialTick); + float yawRotation = this + .interpolateRotation(player.prevRotationYawHead, player.rotationYawHead, + partialTick); + float pitch; + final float zeropointsixtwofive = 0.0625F; - float yawOffset = this.interpolateRotation(player.prevRenderYawOffset, player.renderYawOffset, partialTick); - float yawRotation = this.interpolateRotation(player.prevRotationYawHead, player.rotationYawHead, partialTick); - float pitch; - final float zeropointsixtwofive = 0.0625F; + if (player.isRiding() && player.ridingEntity instanceof EntityLivingBase) { + EntityLivingBase entitylivingbase1 = (EntityLivingBase) player.ridingEntity; + yawOffset = this.interpolateRotation(entitylivingbase1.prevRenderYawOffset, + entitylivingbase1.renderYawOffset, partialTick); + pitch = MathHelper.wrapAngleTo180_float(yawRotation - yawOffset); - if (player.isRiding() && player.ridingEntity instanceof EntityLivingBase) - { - EntityLivingBase entitylivingbase1 = (EntityLivingBase) player.ridingEntity; - yawOffset = this.interpolateRotation(entitylivingbase1.prevRenderYawOffset, entitylivingbase1.renderYawOffset, partialTick); - pitch = MathHelper.wrapAngleTo180_float(yawRotation - yawOffset); + if (pitch < -85.0F) { + pitch = -85.0F; + } - if (pitch < -85.0F) - { - pitch = -85.0F; - } + if (pitch >= 85.0F) { + pitch = 85.0F; + } - if (pitch >= 85.0F) - { - pitch = 85.0F; - } + yawOffset = yawRotation - pitch; - yawOffset = yawRotation - pitch; + if (pitch * pitch > 2500.0F) { + yawOffset += pitch * 0.2F; + } + } - if (pitch * pitch > 2500.0F) - { - yawOffset += pitch * 0.2F; - } - } + pitch = this.handleRotationFloat(player, partialTick); + float bodyRotation = player.prevRotationPitch + + (player.rotationPitch - player.prevRotationPitch) * partialTick; + float limbSwing = player.prevLimbSwingAmount + + (player.limbSwingAmount - player.prevLimbSwingAmount) * partialTick; + float limbSwingMod = player.limbSwing - player.limbSwingAmount * (1.0F - partialTick); + //TPlayerStats stats = TPlayerStats.get(player); + ArmorExtended armor = ArmorProxyClient.armorExtended; //TODO: Do this for every player, not just the client + if (armor.inventory[1] != null) { + Item item = armor.inventory[1].getItem(); + ModelBiped model = item.getArmorModel(player, armor.inventory[1], 4); - pitch = this.handleRotationFloat(player, partialTick); - float bodyRotation = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * partialTick; - float limbSwing = player.prevLimbSwingAmount + (player.limbSwingAmount - player.prevLimbSwingAmount) * partialTick; - float limbSwingMod = player.limbSwing - player.limbSwingAmount * (1.0F - partialTick); - //TPlayerStats stats = TPlayerStats.get(player); - ArmorExtended armor = ArmorProxyClient.armorExtended; //TODO: Do this for every player, not just the client - if (armor.inventory[1] != null) - { - Item item = armor.inventory[1].getItem(); - ModelBiped model = item.getArmorModel(player, armor.inventory[1], 4); + if (item instanceof IAccessoryModel) { + this.mc.getTextureManager().bindTexture( + ((IAccessoryModel) item).getWearbleTexture(player, armor.inventory[1], 1)); + model.setLivingAnimations(player, limbSwingMod, limbSwing, partialTick); + model.render(player, limbSwingMod, limbSwing, pitch, yawRotation - yawOffset, + bodyRotation, zeropointsixtwofive); + } + } - if (item instanceof IAccessoryModel) - { - this.mc.getTextureManager().bindTexture(((IAccessoryModel) item).getWearbleTexture(player, armor.inventory[1], 1)); - model.setLivingAnimations(player, limbSwingMod, limbSwing, partialTick); - model.render(player, limbSwingMod, limbSwing, pitch, yawRotation - yawOffset, bodyRotation, zeropointsixtwofive); - } - } + if (armor.inventory[3] != null) { + Item item = armor.inventory[3].getItem(); + ModelBiped model = item.getArmorModel(player, armor.inventory[3], 5); - if (armor.inventory[3] != null) - { - Item item = armor.inventory[3].getItem(); - ModelBiped model = item.getArmorModel(player, armor.inventory[3], 5); + if (item instanceof IAccessoryModel) { + this.mc.getTextureManager().bindTexture( + ((IAccessoryModel) item).getWearbleTexture(player, armor.inventory[1], 1)); + model.setLivingAnimations(player, limbSwingMod, limbSwing, partialTick); + model.render(player, limbSwingMod, limbSwing, pitch, yawRotation - yawOffset, + bodyRotation, zeropointsixtwofive); + } + } + } - if (item instanceof IAccessoryModel) - { - this.mc.getTextureManager().bindTexture(((IAccessoryModel) item).getWearbleTexture(player, armor.inventory[1], 1)); - model.setLivingAnimations(player, limbSwingMod, limbSwing, partialTick); - model.render(player, limbSwingMod, limbSwing, pitch, yawRotation - yawOffset, bodyRotation, zeropointsixtwofive); - } - } - } + private float interpolateRotation(float par1, float par2, float par3) { + float f3; - private float interpolateRotation (float par1, float par2, float par3) - { - float f3; + for (f3 = par2 - par1; f3 < -180.0F; f3 += 360.0F) { + ; + } - for (f3 = par2 - par1; f3 < -180.0F; f3 += 360.0F) - { - ; - } + while (f3 >= 180.0F) { + f3 -= 360.0F; + } - while (f3 >= 180.0F) - { - f3 -= 360.0F; - } + return par1 + par3 * f3; + } - return par1 + par3 * f3; - } - - protected float handleRotationFloat (EntityLivingBase par1EntityLivingBase, float par2) - { - return (float) par1EntityLivingBase.ticksExisted + par2; - } + protected float handleRotationFloat(EntityLivingBase par1EntityLivingBase, float par2) { + return (float) par1EntityLivingBase.ticksExisted + par2; + } } diff --git a/src/main/java/tconstruct/armor/items/HeartCanister.java b/src/main/java/tconstruct/armor/items/HeartCanister.java index 7f06c5f0..a6e1ff35 100644 --- a/src/main/java/tconstruct/armor/items/HeartCanister.java +++ b/src/main/java/tconstruct/armor/items/HeartCanister.java @@ -31,7 +31,7 @@ public class HeartCanister extends CraftingItem implements IHealthAccessory if (!world.isRemote && meta == 2) { TPlayerStats stats = TPlayerStats.get(player); - if (stats != null) + if (stats != null && stats.armor != null) { ArmorExtended armor = stats.armor; ItemStack slotStack = armor.getStackInSlot(6); diff --git a/src/main/java/tconstruct/client/ArmorControls.java b/src/main/java/tconstruct/client/ArmorControls.java index 22424d98..e7f33c46 100644 --- a/src/main/java/tconstruct/client/ArmorControls.java +++ b/src/main/java/tconstruct/client/ArmorControls.java @@ -1,183 +1,222 @@ package tconstruct.client; -import cpw.mods.fml.common.gameevent.TickEvent.Type; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.InputEvent; import mantle.common.network.AbstractPacket; +import modwarriors.notenoughkeys.api.Api; +import modwarriors.notenoughkeys.api.KeyBindingPressedEvent; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; import tconstruct.TConstruct; -import tconstruct.armor.*; +import tconstruct.armor.ArmorProxyClient; +import tconstruct.armor.ArmorProxyCommon; +import tconstruct.armor.PlayerAbilityHelper; import tconstruct.armor.items.TravelGear; -import tconstruct.util.network.*; +import tconstruct.util.network.AccessoryInventoryPacket; +import tconstruct.util.network.BeltPacket; +import tconstruct.util.network.DoubleJumpPacket; +import tconstruct.util.network.GogglePacket; -public class ArmorControls extends TKeyHandler -{ - public static final String keybindCategory = "tconstruct.keybindings"; - public static KeyBinding armorKey = new KeyBinding("key.tarmor", 24, keybindCategory); - public static KeyBinding toggleGoggles = new KeyBinding("key.tgoggles", 34, keybindCategory); - public static KeyBinding beltSwap = new KeyBinding("key.tbelt", 48, keybindCategory); - public static KeyBinding zoomKey = new KeyBinding("key.tzoom", 44, keybindCategory); //TODO: Make this hold, not toggle - static KeyBinding jumpKey; - static KeyBinding invKey; - static Minecraft mc; +public class ArmorControls { + public static final String keybindCategory = "tconstruct.keybindings"; + public static final String[] keyDescs = new String[] { "key.tarmor", "key.tgoggles", + "key.tbelt", "key.tzoom" + }; + public static KeyBinding armorKey = new KeyBinding(keyDescs[0], 24, keybindCategory); + public static KeyBinding toggleGoggles = new KeyBinding(keyDescs[1], 34, keybindCategory); + public static KeyBinding beltSwap = new KeyBinding(keyDescs[2], 48, keybindCategory); + public static KeyBinding zoomKey = new KeyBinding(keyDescs[3], 44, + keybindCategory); //TODO: Make this hold, not toggle + static KeyBinding jumpKey; + static KeyBinding invKey; + static Minecraft mc; - boolean jumping; - int midairJumps = 0; - boolean climbing = false; - boolean onGround = false; - public static boolean zoom = false; - boolean activeGoggles = false; //TODO: Set this on server login + boolean jumping; + int midairJumps = 0; + boolean climbing = false; + boolean onGround = false; + public static boolean zoom = false; + boolean activeGoggles = false; //TODO: Set this on server login - int currentTab = 1; + int currentTab = 1; - // boolean onStilts = false; + // boolean onStilts = false; - public ArmorControls() - { - super(new KeyBinding[] { armorKey, toggleGoggles, beltSwap, zoomKey }, new boolean[] { false, false, false, false }, getVanillaKeyBindings(), new boolean[] { false, false }); - /*ClientRegistry.registerKeyBinding(armorKey); - ClientRegistry.registerKeyBinding(refreshCapes); - ClientRegistry.registerKeyBinding(toggleGoggles); - ClientRegistry.registerKeyBinding(beltSwap); - ClientRegistry.registerKeyBinding(zoomKey);*/ - } + private final KeyBinding[] keys; - private static KeyBinding[] getVanillaKeyBindings () - { - mc = Minecraft.getMinecraft(); - jumpKey = mc.gameSettings.keyBindJump; - invKey = mc.gameSettings.keyBindInventory; - return new KeyBinding[] { jumpKey, invKey }; - } + public ArmorControls() { + getVanillaKeyBindings(); + this.keys = new KeyBinding[] { + ArmorControls.armorKey, + ArmorControls.toggleGoggles, + ArmorControls.beltSwap, + ArmorControls.zoomKey, + null, null + }; - @Override - public void keyDown (Type types, KeyBinding kb, boolean tickEnd, boolean isRepeat) - { - if (tickEnd && mc.theWorld != null) - { - if (kb == armorKey && mc.currentScreen == null) // Extended Armor - { - openArmorGui();// mc.thePlayer.username); - } + } - if (kb == jumpKey) // Double jump - { - if (mc.thePlayer.capabilities.isCreativeMode) - return; + public void registerKeys() { + // Register bindings + for (KeyBinding key : this.keys) { + if (key != null) + ClientRegistry.registerKeyBinding(key); + } + if (Loader.isModLoaded("notenoughkeys")) + Api.registerMod(TConstruct.modID, ArmorControls.keyDescs); + // Add mc keys + this.keys[4] = ArmorControls.jumpKey; + this.keys[5] = ArmorControls.invKey; + } - if (jumping && midairJumps > 0) - { - mc.thePlayer.motionY = 0.42D; - mc.thePlayer.fallDistance = 0; + private static KeyBinding[] getVanillaKeyBindings() { + mc = Minecraft.getMinecraft(); + jumpKey = mc.gameSettings.keyBindJump; + invKey = mc.gameSettings.keyBindInventory; + return new KeyBinding[] { jumpKey, invKey }; + } - if (mc.thePlayer.isPotionActive(Potion.jump)) - { - mc.thePlayer.motionY += (double) ((float) (mc.thePlayer.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F); - } + @SubscribeEvent + public void mouseEvent(InputEvent.MouseInputEvent event) { + if (!Loader.isModLoaded("notenoughkeys")) + this.checkKeys(); + } - midairJumps--; - resetFallDamage(); - } + @SubscribeEvent + public void keyEvent(InputEvent.KeyInputEvent event) { + if (!Loader.isModLoaded("notenoughkeys")) + this.checkKeys(); + } - if (!jumping) - { - jumping = mc.thePlayer.isAirBorne; - ItemStack shoes = mc.thePlayer.getCurrentArmor(0); - if (shoes != null && shoes.hasTagCompound() && shoes.getTagCompound().hasKey("TinkerArmor")) - { - NBTTagCompound shoeTag = shoes.getTagCompound().getCompoundTag("TinkerArmor"); - midairJumps += shoeTag.getInteger("Double-Jump"); - } - ItemStack wings = mc.thePlayer.getCurrentArmor(1); - if (wings != null && wings.hasTagCompound() && wings.getTagCompound().hasKey("TinkerArmor")) - { - NBTTagCompound shoeTag = wings.getTagCompound().getCompoundTag("TinkerArmor"); - midairJumps += shoeTag.getInteger("Double-Jump"); - } - } - } + @Optional.Method(modid = "notenoughkeys") + @SubscribeEvent + public void keyEventSpecial(KeyBindingPressedEvent event) { + this.keyPressed(event.keyBinding); + } - if (mc.currentScreen == null) - { - if (kb == toggleGoggles) - { - ItemStack goggles = mc.thePlayer.getCurrentArmor(3); - if (goggles != null && goggles.getItem() instanceof TravelGear) //TODO: Genericize this - { - activeGoggles = !activeGoggles; - PlayerAbilityHelper.toggleGoggles(mc.thePlayer, activeGoggles); - toggleGoggles(); - } - } - if (kb == beltSwap) - { - if (ArmorProxyClient.armorExtended.inventory[3] != null) - { - PlayerAbilityHelper.swapBelt(mc.thePlayer, ArmorProxyClient.armorExtended); - toggleBelt(); - } - } - if (kb == zoomKey) - zoom = !zoom; - } - } - } + private void checkKeys() { + for (KeyBinding key : this.keys) { + if (this.isKeyActive(key.getKeyCode())) { + this.keyPressed(key); + } + } + } - @Override - public void keyUp (Type types, KeyBinding kb, boolean tickEnd) - { - // landOnGround(); - } + private boolean isKeyActive(int keyCode) { + if (keyCode < 0) + return Mouse.isButtonDown(keyCode + 100); + else + return Keyboard.isKeyDown(keyCode); + } - public void landOnGround () - { - midairJumps = 0; - jumping = false; - } + private void keyPressed(KeyBinding key) { + if (key == ArmorControls.armorKey) { + openArmorGui(); + } + if (key == ArmorControls.jumpKey) { + if (mc.thePlayer.capabilities.isCreativeMode) + return; - public void resetControls () - { - midairJumps = 0; - jumping = false; - climbing = false; - onGround = false; - } + if (jumping && midairJumps > 0) { + mc.thePlayer.motionY = 0.42D; + mc.thePlayer.fallDistance = 0; - void resetFallDamage () - { - AbstractPacket packet = new DoubleJumpPacket(); - updateServer(packet); - } + if (mc.thePlayer.isPotionActive(Potion.jump)) { + mc.thePlayer.motionY += (double) ( + (float) (mc.thePlayer.getActivePotionEffect(Potion.jump).getAmplifier() + + 1) * 0.1F); + } - public static void openArmorGui () - { - AbstractPacket packet = new AccessoryInventoryPacket(ArmorProxyCommon.armorGuiID); - updateServer(packet); - } + midairJumps--; + resetFallDamage(); + } - public static void openKnapsackGui () - { - AbstractPacket packet = new AccessoryInventoryPacket(ArmorProxyCommon.knapsackGuiID); - updateServer(packet); - } + if (!jumping) { + jumping = mc.thePlayer.isAirBorne; + ItemStack shoes = mc.thePlayer.getCurrentArmor(0); + if (shoes != null && shoes.hasTagCompound() && shoes.getTagCompound() + .hasKey("TinkerArmor")) { + NBTTagCompound shoeTag = shoes.getTagCompound().getCompoundTag("TinkerArmor"); + midairJumps += shoeTag.getInteger("Double-Jump"); + } + ItemStack wings = mc.thePlayer.getCurrentArmor(1); + if (wings != null && wings.hasTagCompound() && wings.getTagCompound() + .hasKey("TinkerArmor")) { + NBTTagCompound shoeTag = wings.getTagCompound().getCompoundTag("TinkerArmor"); + midairJumps += shoeTag.getInteger("Double-Jump"); + } + } + } + if (mc.currentScreen == null) { + if (key == ArmorControls.toggleGoggles) { + ItemStack goggles = mc.thePlayer.getCurrentArmor(3); + if (goggles != null && goggles + .getItem() instanceof TravelGear) //TODO: Genericize this + { + activeGoggles = !activeGoggles; + PlayerAbilityHelper.toggleGoggles(mc.thePlayer, activeGoggles); + toggleGoggles(); + } + } + if (key == ArmorControls.beltSwap) { + if (ArmorProxyClient.armorExtended.inventory[3] != null) { + PlayerAbilityHelper.swapBelt(mc.thePlayer, ArmorProxyClient.armorExtended); + toggleBelt(); + } + } + if (key == ArmorControls.zoomKey) { + zoom = !zoom; + } + } + } - private void toggleGoggles () - { - AbstractPacket packet = new GogglePacket(activeGoggles); - updateServer(packet); - } + public void landOnGround() { + midairJumps = 0; + jumping = false; + } - private void toggleBelt () - { - AbstractPacket packet = new BeltPacket(); - updateServer(packet); - } + public void resetControls() { + midairJumps = 0; + jumping = false; + climbing = false; + onGround = false; + } - static void updateServer (AbstractPacket abstractPacket) - { - TConstruct.packetPipeline.sendToServer(abstractPacket); - } + void resetFallDamage() { + AbstractPacket packet = new DoubleJumpPacket(); + updateServer(packet); + } + + public static void openArmorGui() { + AbstractPacket packet = new AccessoryInventoryPacket(ArmorProxyCommon.armorGuiID); + updateServer(packet); + } + + public static void openKnapsackGui() { + AbstractPacket packet = new AccessoryInventoryPacket(ArmorProxyCommon.knapsackGuiID); + updateServer(packet); + } + + private void toggleGoggles() { + AbstractPacket packet = new GogglePacket(activeGoggles); + updateServer(packet); + } + + private void toggleBelt() { + AbstractPacket packet = new BeltPacket(); + updateServer(packet); + } + + static void updateServer(AbstractPacket abstractPacket) { + TConstruct.packetPipeline.sendToServer(abstractPacket); + } } diff --git a/src/main/java/tconstruct/client/BlockSkinRenderHelper.java b/src/main/java/tconstruct/client/BlockSkinRenderHelper.java index 510555e5..ef49c145 100644 --- a/src/main/java/tconstruct/client/BlockSkinRenderHelper.java +++ b/src/main/java/tconstruct/client/BlockSkinRenderHelper.java @@ -7,6 +7,7 @@ import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraftforge.fluids.FluidRegistry; +import org.lwjgl.opengl.GL11; public class BlockSkinRenderHelper { @@ -852,28 +853,33 @@ public class BlockSkinRenderHelper } public static boolean renderLiquidBlock (IIcon stillIcon, IIcon flowingIcon, int x, int y, int z, RenderBlocks renderer, IBlockAccess world, boolean extraBright) + { + return renderLiquidBlock(stillIcon, flowingIcon, x, y, z, renderer, world, extraBright, 0xffffffff); + } + + public static boolean renderLiquidBlock (IIcon stillIcon, IIcon flowingIcon, int x, int y, int z, RenderBlocks renderer, IBlockAccess world, boolean extraBright, int color) { Block block = Blocks.stone; - int var5 = block.colorMultiplier(world, x, y, z); - float var6 = (float) (var5 >> 16 & 255) / 255.0F; - float var7 = (float) (var5 >> 8 & 255) / 255.0F; - float var8 = (float) (var5 & 255) / 255.0F; + float alpha = (float) (color >> 24 & 255) / 255.0F; + float red = (float) (color >> 16 & 255) / 255.0F; + float green = (float) (color >> 8 & 255) / 255.0F; + float blue = (float) (color & 255) / 255.0F; if (EntityRenderer.anaglyphEnable) { - float var9 = (var6 * 30.0F + var7 * 59.0F + var8 * 11.0F) / 100.0F; - float var10 = (var6 * 30.0F + var7 * 70.0F) / 100.0F; - float var11 = (var6 * 30.0F + var8 * 70.0F) / 100.0F; - var6 = var9; - var7 = var10; - var8 = var11; + float var9 = (red * 30.0F + green * 59.0F + blue * 11.0F) / 100.0F; + float var10 = (red * 30.0F + green * 70.0F) / 100.0F; + float var11 = (red * 30.0F + blue * 70.0F) / 100.0F; + red = var9; + green = var10; + blue = var11; } if (extraBright) { - var6 = Math.max(1.0f, var6 + 0.5f); - var7 = Math.max(1.0f, var7 + 0.5f); - var8 = Math.max(1.0f, var8 + 0.5f); + red = Math.max(1.0f, red + 0.5f); + green = Math.max(1.0f, green + 0.5f); + blue = Math.max(1.0f, blue + 0.5f); } // safety @@ -885,11 +891,18 @@ public class BlockSkinRenderHelper boolean raf = renderer.renderAllFaces; renderer.renderAllFaces = true; + //Tessellator.instance.setColorRGBA_F(alpha, red, green, blue); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1f); + boolean ret; if (Minecraft.isAmbientOcclusionEnabled()) - ret = renderFakeBlockWithAmbientOcclusion(stillIcon, flowingIcon, x, y, z, var6, var7, var8, renderer, world); + ret = renderFakeBlockWithAmbientOcclusion(stillIcon, flowingIcon, x, y, z, red, green, blue, renderer, world); else - ret = renderFakeBlockWithColorMultiplier(stillIcon, flowingIcon, x, y, z, var6, var7, var8, renderer, world); + ret = renderFakeBlockWithColorMultiplier(stillIcon, flowingIcon, x, y, z, red, green, blue, renderer, world); + + GL11.glDisable(GL11.GL_BLEND); renderer.renderAllFaces = raf; return ret; diff --git a/src/main/java/tconstruct/client/TKeyHandler.java b/src/main/java/tconstruct/client/TKeyHandler.java deleted file mode 100644 index dcb21dd8..00000000 --- a/src/main/java/tconstruct/client/TKeyHandler.java +++ /dev/null @@ -1,142 +0,0 @@ -package tconstruct.client; - -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.common.gameevent.TickEvent.Type; -import cpw.mods.fml.relauncher.Side; -import java.util.EnumSet; -import net.minecraft.client.settings.KeyBinding; -import org.lwjgl.input.*; - -public abstract class TKeyHandler -{ - public KeyBinding[] keyBindings; - public KeyBinding[] vKeyBindings; - public boolean[] keyDown; - public boolean[] repeatings; - public boolean[] vRepeatings; - public boolean isDummy; - - /** - * Pass an array of keybindings and a repeat flag for each one - * - * @param keyBindings - * @param repeatings - */ - public TKeyHandler(KeyBinding[] keyBindings, boolean[] repeatings, KeyBinding[] vanillaKeys, boolean[] vanillaRepeatings) - { - assert keyBindings.length == repeatings.length : "You need to pass two arrays of identical length"; - assert vanillaKeys.length == vanillaRepeatings.length : "You need to pass two arrays of identical length"; - this.keyBindings = keyBindings; - this.repeatings = repeatings; - this.vKeyBindings = vanillaKeys; - this.vRepeatings = vanillaRepeatings; - this.keyDown = new boolean[keyBindings.length + vanillaKeys.length]; - } - - /** - * Register the keys into the system. You will do your own keyboard - * management elsewhere. No events will fire if you use this method - * - * @param keyBindings - */ - public TKeyHandler(KeyBinding[] keyBindings) - { - this.keyBindings = keyBindings; - this.isDummy = true; - } - - public KeyBinding[] getKeyBindings () - { - return this.keyBindings; - } - - @SubscribeEvent - public void onTick (ClientTickEvent event) - { - if (event.side == Side.CLIENT) - { - if (event.phase == Phase.START) - keyTick(event.type, false); - else if (event.phase == Phase.END) - keyTick(event.type, true); - } - - } - - public void keyTick (Type type, boolean tickEnd) - { - for (int i = 0; i < keyBindings.length; i++) - { - KeyBinding keyBinding = keyBindings[i]; - int keyCode = keyBinding.getKeyCode(); - boolean state = (keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode)); - if (state != keyDown[i] || (state && repeatings[i])) - { - if (state) - { - keyDown(type, keyBinding, tickEnd, state != keyDown[i]); - } - else - { - keyUp(type, keyBinding, tickEnd); - } - if (tickEnd) - { - keyDown[i] = state; - } - } - } - for (int i = 0; i < vKeyBindings.length; i++) - { - KeyBinding keyBinding = vKeyBindings[i]; - int keyCode = keyBinding.getKeyCode(); - boolean state = (keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode)); - if (state != keyDown[i + keyBindings.length] || (state && vRepeatings[i])) - { - if (state) - { - keyDown(type, keyBinding, tickEnd, state != keyDown[i + keyBindings.length]); - } - else - { - keyUp(type, keyBinding, tickEnd); - } - if (tickEnd) - { - keyDown[i + keyBindings.length] = state; - } - } - } - } - - /** - * Called when the key is first in the down position on any tick from the - * {@link #ticks()} set. Will be called subsequently with isRepeat set to - * true - * - * @see #keyUp(EnumSet, KeyBinding, boolean) - * - * @param types - * the type(s) of tick that fired when this key was first down - * @param tickEnd - * was it an end or start tick which fired the key - * @param isRepeat - * is it a repeat key event - */ - public abstract void keyDown (Type types, KeyBinding kb, boolean tickEnd, boolean isRepeat); - - /** - * Fired once when the key changes state from down to up - * - * @see #keyDown(EnumSet, KeyBinding, boolean, boolean) - * - * @param types - * the type(s) of tick that fired when this key was first down - * @param tickEnd - * was it an end or start tick which fired the key - */ - public abstract void keyUp (Type types, KeyBinding kb, boolean tickEnd); - -} diff --git a/src/main/java/tconstruct/smeltery/TinkerSmeltery.java b/src/main/java/tconstruct/smeltery/TinkerSmeltery.java index 7bf9bdc7..fca36892 100644 --- a/src/main/java/tconstruct/smeltery/TinkerSmeltery.java +++ b/src/main/java/tconstruct/smeltery/TinkerSmeltery.java @@ -669,6 +669,10 @@ public class TinkerSmeltery if (FluidContainerRegistry.fillFluidContainer(new FluidStack(TinkerSmeltery.pigIronFluid, 1000), new ItemStack(Items.bucket)) == null) FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(TinkerSmeltery.pigIronFluid, 1000), new ItemStack(TinkerSmeltery.buckets, 1, 26), new ItemStack(Items.bucket))); + // blueslime is registered here too because we have the bucket here + if (FluidContainerRegistry.fillFluidContainer(new FluidStack(TinkerWorld.blueSlimeFluid, 1000), new ItemStack(Items.bucket)) == null) + FluidContainerRegistry.registerFluidContainer(new FluidContainerRegistry.FluidContainerData(new FluidStack(TinkerWorld.blueSlimeFluid, 1000), new ItemStack(TinkerSmeltery.buckets, 1, 24), new ItemStack(Items.bucket))); + TinkerSmeltery.fluids = new Fluid[] { TinkerSmeltery.moltenIronFluid, TinkerSmeltery.moltenGoldFluid, TinkerSmeltery.moltenCopperFluid, TinkerSmeltery.moltenTinFluid, TinkerSmeltery.moltenAluminumFluid, TinkerSmeltery.moltenCobaltFluid, TinkerSmeltery.moltenArditeFluid, TinkerSmeltery.moltenBronzeFluid, TinkerSmeltery.moltenAlubrassFluid, TinkerSmeltery.moltenManyullynFluid, TinkerSmeltery.moltenAlumiteFluid, TinkerSmeltery.moltenObsidianFluid, TinkerSmeltery.moltenSteelFluid, TinkerSmeltery.moltenGlassFluid, TinkerSmeltery.moltenStoneFluid, TinkerSmeltery.moltenEmeraldFluid, TinkerSmeltery.bloodFluid, TinkerSmeltery.moltenNickelFluid, TinkerSmeltery.moltenLeadFluid, TinkerSmeltery.moltenSilverFluid, TinkerSmeltery.moltenShinyFluid, TinkerSmeltery.moltenInvarFluid, TinkerSmeltery.moltenElectrumFluid, TinkerSmeltery.moltenEnderFluid, TinkerWorld.blueSlimeFluid, TinkerSmeltery.glueFluid, TinkerSmeltery.pigIronFluid }; TinkerSmeltery.fluidBlocks = new Block[] { TinkerSmeltery.moltenIron, TinkerSmeltery.moltenGold, TinkerSmeltery.moltenCopper, TinkerSmeltery.moltenTin, TinkerSmeltery.moltenAluminum, TinkerSmeltery.moltenCobalt, TinkerSmeltery.moltenArdite, TinkerSmeltery.moltenBronze, TinkerSmeltery.moltenAlubrass, TinkerSmeltery.moltenManyullyn, TinkerSmeltery.moltenAlumite, TinkerSmeltery.moltenObsidian, TinkerSmeltery.moltenSteel, TinkerSmeltery.moltenGlass, TinkerSmeltery.moltenStone, TinkerSmeltery.moltenEmerald, TinkerSmeltery.blood, TinkerSmeltery.moltenNickel, TinkerSmeltery.moltenLead, TinkerSmeltery.moltenSilver, TinkerSmeltery.moltenShiny, TinkerSmeltery.moltenInvar, TinkerSmeltery.moltenElectrum, TinkerSmeltery.moltenEnder, TinkerWorld.slimePool, TinkerSmeltery.glueFluidBlock, TinkerSmeltery.pigIronFluidBlock }; diff --git a/src/main/java/tconstruct/smeltery/gui/SmelteryGui.java b/src/main/java/tconstruct/smeltery/gui/SmelteryGui.java index 57f8c827..97d7f75a 100644 --- a/src/main/java/tconstruct/smeltery/gui/SmelteryGui.java +++ b/src/main/java/tconstruct/smeltery/gui/SmelteryGui.java @@ -5,6 +5,7 @@ import java.util.*; import net.minecraft.client.renderer.*; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; import net.minecraft.util.*; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; @@ -159,14 +160,17 @@ public class SmelteryGui extends ActiveContainerGui this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); if (logic.fuelGague > 0) { - IIcon lavaIcon = logic.getFuelIcon(); + FluidStack fuelStack = logic.getFuel(); + IIcon lavaIcon = fuelStack.getFluid().getStillIcon(); + if(lavaIcon == null) + lavaIcon = Blocks.lava.getIcon(0, 0); int fuel = logic.getScaledFuelGague(52); int count = 0; while (fuel > 0) { int size = fuel >= 16 ? 16 : fuel; fuel -= size; - drawLiquidRect(cornerX + 117, (cornerY + 68) - size - 16 * count, lavaIcon, 12, size); + drawLiquidRect(cornerX + 117, (cornerY + 68) - size - 16 * count, lavaIcon, 12, size, fuelStack.getFluid().getColor(fuelStack)); count++; } } @@ -183,6 +187,7 @@ public class SmelteryGui extends ActiveContainerGui { FluidStack liquid = logic.moltenMetal.get(i); IIcon icon = liquid.getFluid().getStillIcon(); + int color = liquid.getFluid().getColor(liquid); if (icon == null) continue; @@ -193,10 +198,10 @@ public class SmelteryGui extends ActiveContainerGui { int v = Math.min(16, h); // we render in 16x16 squares so the texture doesn't get distorted - drawLiquidRect(cornerX + basePos + 00, (cornerY + 68) - h - base, icon, 16, v); - drawLiquidRect(cornerX + basePos + 16, (cornerY + 68) - h - base, icon, 16, v); - drawLiquidRect(cornerX + basePos + 32, (cornerY + 68) - h - base, icon, 16, v); - drawLiquidRect(cornerX + basePos + 48, (cornerY + 68) - h - base, icon, 4, v); + drawLiquidRect(cornerX + basePos + 00, (cornerY + 68) - h - base, icon, 16, v, color); + drawLiquidRect(cornerX + basePos + 16, (cornerY + 68) - h - base, icon, 16, v, color); + drawLiquidRect(cornerX + basePos + 32, (cornerY + 68) - h - base, icon, 16, v, color); + drawLiquidRect(cornerX + basePos + 48, (cornerY + 68) - h - base, icon, 4, v, color); h -= 16; } base += height; @@ -492,7 +497,7 @@ public class SmelteryGui extends ActiveContainerGui } } - public void drawLiquidRect (int startU, int startV, IIcon icon, int endU, int endV) + public void drawLiquidRect (int startU, int startV, IIcon icon, int endU, int endV, int color) { float top = icon.getInterpolatedV(16 - endV); float bottom = icon.getMaxV(); @@ -500,6 +505,7 @@ public class SmelteryGui extends ActiveContainerGui float right = icon.getInterpolatedU(endU); Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(color); tessellator.addVertexWithUV(startU + 0, startV + endV, this.zLevel, left, bottom);//Bottom left tessellator.addVertexWithUV(startU + endU, startV + endV, this.zLevel, right, bottom);//Bottom right tessellator.addVertexWithUV(startU + endU, startV + 0, this.zLevel, right, top);//Top right diff --git a/src/main/java/tconstruct/smeltery/logic/CastingBlockLogic.java b/src/main/java/tconstruct/smeltery/logic/CastingBlockLogic.java index b1246575..6429a186 100644 --- a/src/main/java/tconstruct/smeltery/logic/CastingBlockLogic.java +++ b/src/main/java/tconstruct/smeltery/logic/CastingBlockLogic.java @@ -90,7 +90,7 @@ public abstract class CastingBlockLogic extends InventoryLogic implements IFluid public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain) { // only same liquid - if (liquid.getFluid() != resource.getFluid()) + if (liquid != null && liquid.getFluid() != resource.getFluid()) return null; return drain(resource.amount, doDrain); diff --git a/src/main/java/tconstruct/smeltery/logic/SmelteryLogic.java b/src/main/java/tconstruct/smeltery/logic/SmelteryLogic.java index b34295b8..4924952d 100644 --- a/src/main/java/tconstruct/smeltery/logic/SmelteryLogic.java +++ b/src/main/java/tconstruct/smeltery/logic/SmelteryLogic.java @@ -667,17 +667,17 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci } @SideOnly(Side.CLIENT) - public IIcon getFuelIcon () + public FluidStack getFuel() { - IIcon defaultLava = Blocks.lava.getIcon(0, 0); if (activeLavaTank == null) - return defaultLava; + // sane default + return new FluidStack(FluidRegistry.LAVA, 0); TileEntity tankContainer = worldObj.getTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z); if (tankContainer instanceof IFluidHandler) - return ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN)[0].fluid.getFluid().getStillIcon(); + return ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN)[0].fluid; - return defaultLava; + return new FluidStack(FluidRegistry.LAVA, 0); } public FluidStack getResultFor (ItemStack stack) diff --git a/src/main/java/tconstruct/smeltery/model/BlockRenderCastingChannel.java b/src/main/java/tconstruct/smeltery/model/BlockRenderCastingChannel.java index 3c7d4cae..ade8edf3 100644 --- a/src/main/java/tconstruct/smeltery/model/BlockRenderCastingChannel.java +++ b/src/main/java/tconstruct/smeltery/model/BlockRenderCastingChannel.java @@ -187,9 +187,9 @@ public class BlockRenderCastingChannel implements ISimpleBlockRenderingHandler if (fluid.canBePlacedInWorld() && !useFlowingTexture) BlockSkinRenderHelper.renderMetadataBlock(fluid.getBlock(), 0, x, y, z, renderer, world); else if (useFlowingTexture) - BlockSkinRenderHelper.renderLiquidBlock(fluid.getFlowingIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world); + BlockSkinRenderHelper.renderLiquidBlock(fluid.getFlowingIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world, false, fluid.getColor(fluidStack)); else - BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world); + BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world, false, fluid.getColor(fluidStack)); } private void renderStandardBlock (Block block, int meta, RenderBlocks renderer) diff --git a/src/main/java/tconstruct/smeltery/model/CastingBlockRender.java b/src/main/java/tconstruct/smeltery/model/CastingBlockRender.java index e5d17669..e6337b13 100644 --- a/src/main/java/tconstruct/smeltery/model/CastingBlockRender.java +++ b/src/main/java/tconstruct/smeltery/model/CastingBlockRender.java @@ -196,7 +196,7 @@ public class CastingBlockRender implements ISimpleBlockRenderingHandler renderer.setRenderBounds(minX, minHeight, minZ, maxX, minHeight + height, maxZ); Fluid fluid = logic.liquid.getFluid(); - BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world); + BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world, false, fluid.getColor(logic.liquid)); } } } @@ -275,7 +275,7 @@ public class CastingBlockRender implements ISimpleBlockRenderingHandler { Fluid fluid = logic.liquid.getFluid(); renderer.setRenderBounds(xMin, yMin, zMin, xMax, 0.625, zMax); - BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world); + BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world, false, fluid.getColor(logic.liquid)); // float xMin = 0.375F, zMin = 0.375F, xMax = 0.625F, // zMax = 0.625F; @@ -299,7 +299,7 @@ public class CastingBlockRender implements ISimpleBlockRenderingHandler break; } renderer.setRenderBounds(xMin, 0.5F, zMin, xMax, 0.625F, zMax); - BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world); + BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world, false, fluid.getColor(logic.liquid)); } } } @@ -403,7 +403,7 @@ public class CastingBlockRender implements ISimpleBlockRenderingHandler renderer.setRenderBounds(minX, minHeight, minZ, maxX, minHeight + height, maxZ); Fluid fluid = logic.liquid.getFluid(); - BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world); + BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world, false, fluid.getColor(logic.liquid)); } } } diff --git a/src/main/java/tconstruct/smeltery/model/SmelteryRender.java b/src/main/java/tconstruct/smeltery/model/SmelteryRender.java index 76c26350..aec438ba 100644 --- a/src/main/java/tconstruct/smeltery/model/SmelteryRender.java +++ b/src/main/java/tconstruct/smeltery/model/SmelteryRender.java @@ -93,7 +93,7 @@ public class SmelteryRender implements ISimpleBlockRenderingHandler if (fluid.canBePlacedInWorld()) BlockSkinRenderHelper.renderMetadataBlock(fluid.getBlock(), 0, xi, from.y + yBase, zi, renderer, world); else - BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), xi, from.y + yBase, zi, renderer, world); + BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), xi, from.y + yBase, zi, renderer, world, false, fluid.getColor(liquid)); } if (countSize == room) diff --git a/src/main/java/tconstruct/smeltery/model/TankRender.java b/src/main/java/tconstruct/smeltery/model/TankRender.java index b73e7ea7..c440894f 100644 --- a/src/main/java/tconstruct/smeltery/model/TankRender.java +++ b/src/main/java/tconstruct/smeltery/model/TankRender.java @@ -45,7 +45,7 @@ public class TankRender implements ISimpleBlockRenderingHandler FluidStack liquid = logic.tank.getFluid(); renderer.setRenderBounds(0.001, 0.001, 0.001, 0.999, logic.getFluidAmountScaled(), 0.999); Fluid fluid = liquid.getFluid(); - BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getStillIcon(), x, y, z, renderer, world, true); + BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getStillIcon(), x, y, z, renderer, world, false, fluid.getColor(liquid)); renderer.setRenderBounds(0, 0.001, 0.001, 0.999, logic.getFluidAmountScaled(), 0.999); } diff --git a/src/main/java/tconstruct/world/TinkerWorld.java b/src/main/java/tconstruct/world/TinkerWorld.java index 71f42aa5..bd14afcb 100644 --- a/src/main/java/tconstruct/world/TinkerWorld.java +++ b/src/main/java/tconstruct/world/TinkerWorld.java @@ -120,8 +120,6 @@ public class TinkerWorld TinkerWorld.slimePool = new SlimeFluid(TinkerWorld.blueSlimeFluid, Material.water).setCreativeTab(TConstructRegistry.blockTab).setStepSound(TinkerWorld.slimeStep).setBlockName("liquid.slime"); GameRegistry.registerBlock(TinkerWorld.slimePool, "liquid.slime"); TinkerWorld.blueSlimeFluid.setBlock(TinkerWorld.slimePool); - //TODO: Add a new bucket for blue slime - //FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(TinkerWorld.blueSlimeFluid, 1000), new ItemStack(TinkerSmeltery.buckets, 1, 24), new ItemStack(Items.bucket))); // Slime Islands TinkerWorld.slimeGel = new SlimeGel().setStepSound(TinkerWorld.slimeStep).setLightOpacity(0).setBlockName("slime.gel");