From 6c0f4cffa09cf172ae776fbe25f2cf23e3e1a654 Mon Sep 17 00:00:00 2001 From: fewizz Date: Wed, 14 Jun 2017 11:17:28 +0300 Subject: [PATCH] Close #35 , Close #36 --- src/api/java/baubles/api/package-info.java | 2 +- src/api/java/thaumcraft/api/package-info.java | 4 +- .../boots/ItemElectricBootsTraveller.java | 9 +- .../item/armor/goggles/ItemNanoGoggles.java | 19 +-- .../armor/goggles/ItemQuantumGoggles.java | 66 +++++----- .../goggles/ItemSolarHelmetRevealing.java | 123 +++--------------- src/main/resources/assets/emt/lang/en_US.lang | 6 +- src/main/resources/assets/emt/lang/ru_RU.lang | 6 +- 8 files changed, 66 insertions(+), 169 deletions(-) diff --git a/src/api/java/baubles/api/package-info.java b/src/api/java/baubles/api/package-info.java index 1cbc8d8..22d01a3 100644 --- a/src/api/java/baubles/api/package-info.java +++ b/src/api/java/baubles/api/package-info.java @@ -1,3 +1,3 @@ -//@API(apiVersion = "1.7.10-1.0.1.5", owner = "Baubles", provides = "Baubles|API") package baubles.api; +@API(apiVersion = "1.7.10-1.0.1.5", owner = "Baubles", provides = "Baubles|API") package baubles.api; import cpw.mods.fml.common.API; diff --git a/src/api/java/thaumcraft/api/package-info.java b/src/api/java/thaumcraft/api/package-info.java index 7e1c4b7..cceaf89 100644 --- a/src/api/java/thaumcraft/api/package-info.java +++ b/src/api/java/thaumcraft/api/package-info.java @@ -1,4 +1,4 @@ -//@API(owner = "Thaumcraft", apiVersion = "4.2.2.0", provides = "Thaumcraft|API") -//package thaumcraft.api; +@API(owner = "Thaumcraft", apiVersion = "4.2.2.0", provides = "Thaumcraft|API") +package thaumcraft.api; import cpw.mods.fml.common.API; diff --git a/src/main/java/emt/item/armor/boots/ItemElectricBootsTraveller.java b/src/main/java/emt/item/armor/boots/ItemElectricBootsTraveller.java index 9117d15..bc04a9a 100644 --- a/src/main/java/emt/item/armor/boots/ItemElectricBootsTraveller.java +++ b/src/main/java/emt/item/armor/boots/ItemElectricBootsTraveller.java @@ -39,7 +39,6 @@ public class ItemElectricBootsTraveller extends ItemArmor implements IElectricIt public float speedBonus = 0.055F; public float jumpBonus = 0.3F; public double transferLimit = 100; - public boolean speedBoostActive = false; public ItemElectricBootsTraveller(ArmorMaterial material, int par3, int par4) { super(material, par3, par4); @@ -116,11 +115,6 @@ public class ItemElectricBootsTraveller extends ItemArmor implements IElectricIt @Override public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { - if (Keys.instance.isBoostKeyDown(player) && Keys.instance.isModeSwitchKeyDown(player)) - { - speedBoostActive = !speedBoostActive; - } - if ((!player.capabilities.isFlying) && (player.moveForward > 0.0F)) { if ((player.worldObj.isRemote) && (!player.isSneaking())) { if (!Thaumcraft.instance.entityEventHandler.prevStep.containsKey(Integer.valueOf(player.getEntityId()))) { @@ -128,7 +122,8 @@ public class ItemElectricBootsTraveller extends ItemArmor implements IElectricIt } player.stepHeight = 1.0F; } - if (speedBoostActive && ((player.onGround || player.capabilities.isFlying) && player.moveForward > 0F)) { + + if (((player.onGround || player.capabilities.isFlying) && player.moveForward > 0F)) { player.moveFlying(0F, 1F, speedBonus); player.jumpMovementFactor = jumpBonus; } diff --git a/src/main/java/emt/item/armor/goggles/ItemNanoGoggles.java b/src/main/java/emt/item/armor/goggles/ItemNanoGoggles.java index 43c03b9..6411b59 100644 --- a/src/main/java/emt/item/armor/goggles/ItemNanoGoggles.java +++ b/src/main/java/emt/item/armor/goggles/ItemNanoGoggles.java @@ -6,6 +6,8 @@ import emt.EMT; import emt.EMT; import emt.util.EMTConfigHandler; import ic2.api.item.ElectricItem; +import ic2.api.item.IC2Items; +import ic2.api.util.Keys; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -52,21 +54,6 @@ public class ItemNanoGoggles extends ItemElectricGoggles { @Override public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { - if (EMTConfigHandler.nightVisionOff == false) { - if (ElectricItem.manager.canUse(itemStack, 1 / 1000)) { - - int x = MathHelper.floor_double(player.posX); - int z = MathHelper.floor_double(player.posZ); - int y = MathHelper.floor_double(player.posY); - - int lightlevel = player.worldObj.getBlockLightValue(x, y, z); - if (lightlevel >= 0) - player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 300, -3)); - ElectricItem.manager.use(itemStack, 1 / 1000, player); - } - else { - player.addPotionEffect(new PotionEffect(Potion.blindness.id, 300, 0, true)); - } - } + IC2Items.getItem("nightvisionGoggles").getItem().onArmorTick(world, player, itemStack); } } diff --git a/src/main/java/emt/item/armor/goggles/ItemQuantumGoggles.java b/src/main/java/emt/item/armor/goggles/ItemQuantumGoggles.java index 03fe2e1..d738054 100644 --- a/src/main/java/emt/item/armor/goggles/ItemQuantumGoggles.java +++ b/src/main/java/emt/item/armor/goggles/ItemQuantumGoggles.java @@ -6,6 +6,9 @@ import emt.EMT; import emt.EMT; import emt.util.EMTConfigHandler; import ic2.api.item.ElectricItem; +import ic2.api.item.IC2Items; +import ic2.core.IC2; +import ic2.core.util.Keyboard; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -16,10 +19,13 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.util.MathHelper; import net.minecraft.world.World; +import java.lang.reflect.Field; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; +import java.util.Set; +import java.util.function.Predicate; public class ItemQuantumGoggles extends ItemNanoGoggles { @@ -62,48 +68,40 @@ public class ItemQuantumGoggles extends ItemNanoGoggles { return 4; } + // MUAHAHAHA @Override public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { - int refill = player.getAir(); - if (ElectricItem.manager.canUse(itemStack, 1000) && refill < 100) { - player.setAir(refill + 200); - ElectricItem.manager.use(itemStack, 1000, null); - } + try { + Field f; + f = Keyboard.class.getDeclaredField("playerKeys"); + f.setAccessible(true); + Map> playerKeys = (Map>) f.get(IC2.keyboard); - Iterator i$ = (new LinkedList(player.getActivePotionEffects())).iterator(); - do { - if (!i$.hasNext()) { - break; - } - { - PotionEffect effect = (PotionEffect) i$.next(); - int id = effect.getPotionID(); - Integer cost = (Integer) potionCost.get(Integer.valueOf(id)); - if (cost != null) { - cost = Integer.valueOf(cost.intValue() * (effect.getAmplifier() + 1)); - if (ElectricItem.manager.canUse(itemStack, cost.intValue())) { - ElectricItem.manager.use(itemStack, cost.intValue(), null); - ItemStack milk = (new ItemStack(Items.milk_bucket)); - player.curePotionEffects(milk); + Enum hub = null; + Set set = playerKeys.get(player); + + if (set != null) { + for (Enum e : set) { + if (e.ordinal() == 6) { + hub = e; } } + set.remove(hub); } - } - while (true); - if (EMTConfigHandler.nightVisionOff == false) { - if (ElectricItem.manager.canUse(itemStack, 1 / 1000)) { - int x = MathHelper.floor_double(player.posX); - int z = MathHelper.floor_double(player.posZ); - int y = MathHelper.floor_double(player.posY); - int lightlevel = player.worldObj.getBlockLightValue(x, y, z); - if (lightlevel >= 0) - player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 300, -3)); - ElectricItem.manager.use(itemStack, 1 / 1000, player); - } - else { - player.addPotionEffect(new PotionEffect(Potion.blindness.id, 300, 0, true)); + IC2Items.getItem("quantumHelmet").getItem().onArmorTick(world, player, itemStack); + + if (hub != null) { + set.add(hub); } + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); } } } diff --git a/src/main/java/emt/item/armor/goggles/ItemSolarHelmetRevealing.java b/src/main/java/emt/item/armor/goggles/ItemSolarHelmetRevealing.java index 9f66c25..61a0a37 100644 --- a/src/main/java/emt/item/armor/goggles/ItemSolarHelmetRevealing.java +++ b/src/main/java/emt/item/armor/goggles/ItemSolarHelmetRevealing.java @@ -24,14 +24,14 @@ import java.util.Map; public class ItemSolarHelmetRevealing extends ItemQuantumGoggles { - private int ticker; + /*private int ticker; private int generating; - private int genDay; - private int genNight; private boolean sunIsUp; private boolean skyIsVisible; private boolean noSunWorld; - private boolean dampPlace; + private boolean dampPlace;*/ + private int genDay; + private int genNight; private static final Map potionCost = new HashMap(); @@ -41,9 +41,9 @@ public class ItemSolarHelmetRevealing extends ItemQuantumGoggles { this.setMaxDamage(27); this.setMaxStackSize(1); this.setCreativeTab(EMT.TAB); - //this.maxCharge = 20000000; //REALLY? - this.genDay = 256; - this.genNight = 128; + // this.maxCharge = 20000000; //REALLY? + this.genDay = 65536; + this.genNight = 4096; maxCharge = 20000000; visDiscount = 7; tier = 4; @@ -76,120 +76,37 @@ public class ItemSolarHelmetRevealing extends ItemQuantumGoggles { return 4; } - @SuppressWarnings("unchecked") @Override public void onArmorTick(World worldObj, EntityPlayer player, ItemStack itemStack) { - if (EMTConfigHandler.nightVisionOff == false) { - if (ElectricItem.manager.canUse(itemStack, 1 / 1000)) { - - int x = MathHelper.floor_double(player.posX); - int z = MathHelper.floor_double(player.posZ); - int y = MathHelper.floor_double(player.posY); - - int lightlevel = player.worldObj.getBlockLightValue(x, y, z); - if (lightlevel >= 0) - player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 300, -3)); - ElectricItem.manager.use(itemStack, 1 / 1000, player); - } - else { - player.addPotionEffect(new PotionEffect(Potion.blindness.id, 300, 0, true)); - } - } - - int refill = player.getAir(); - if (ElectricItem.manager.canUse(itemStack, 1000) && refill < 100) { - player.setAir(refill + 200); - ElectricItem.manager.use(itemStack, 1000, null); - } - - @SuppressWarnings("rawtypes") - Iterator i$ = (new LinkedList(player.getActivePotionEffects())).iterator(); - do { - if (!i$.hasNext()) { - break; - } - { - PotionEffect effect = (PotionEffect) i$.next(); - int id = effect.getPotionID(); - Integer cost = (Integer) potionCost.get(Integer.valueOf(id)); - if (cost != null) { - cost = Integer.valueOf(cost.intValue() * (effect.getAmplifier() + 1)); - if (ElectricItem.manager.canUse(itemStack, cost.intValue())) { - ElectricItem.manager.use(itemStack, cost.intValue(), null); - ItemStack milk = (new ItemStack(Items.milk_bucket)); - player.curePotionEffects(milk); - } - } - } - } - while (true); + super.onArmorTick(worldObj, player, itemStack); if (worldObj.isRemote) { return; } - checkForSun(player); - if (this.generating > 0) { - int energyLeft = this.generating; + + if(worldObj.canBlockSeeTheSky((int)player.posX, (int)player.posY + 1, (int)player.posZ) && !worldObj.isRaining()) { + double enerj = (worldObj.isDaytime() ? (double)genDay : (double) genNight) / 12000D; + for (int i = 0; i < player.inventory.armorInventory.length; i++) { - if (energyLeft > 0) { + if (enerj > 0) { if ((player.inventory.armorInventory[i] != null) && (player.inventory.armorInventory[i].getItem() instanceof IElectricItem)) { - double sentPacket = ElectricItem.manager.charge(player.inventory.armorInventory[i], energyLeft, 4, false, false); - energyLeft -= sentPacket; + double sentPacket = ElectricItem.manager.charge(player.inventory.armorInventory[i], enerj ,4, false, false); + enerj -= sentPacket; } - } - else { + } else { return; } } for (int j = 0; j < player.inventory.mainInventory.length; j++) { - if (energyLeft > 0) { + if (enerj > 0) { if ((player.inventory.mainInventory[j] != null) && (player.inventory.mainInventory[j].getItem() instanceof IElectricItem)) { - double sentPacket = ElectricItem.manager.charge(player.inventory.mainInventory[j], energyLeft, 4, false, false); - energyLeft -= sentPacket; + double sentPacket = ElectricItem.manager.charge(player.inventory.mainInventory[j], enerj, 4, false, false); + enerj -= sentPacket; } - } - else { + } else { return; } } } } - - public int checkForSun(EntityPlayer player) { - if (this.ticker++ % tickRate() == 0) { - updateVisibility(player); - } - if ((this.sunIsUp) && (this.skyIsVisible)) { - this.generating = (0 + this.genDay); - return this.generating; - } - if (this.skyIsVisible) { - this.generating = (0 + this.genNight); - return this.generating; - } - this.generating = 0; - return this.generating; - } - - public void updateVisibility(EntityPlayer player) { - this.dampPlace = (player.worldObj.getWorldChunkManager().getBiomeGenAt((int) player.posX, (int) player.posZ).getIntRainfall() > 0); - this.noSunWorld = player.worldObj.provider.hasNoSky; - Boolean rainWeather = Boolean.valueOf((this.dampPlace) && ((player.worldObj.isRaining()) || (player.worldObj.isThundering()))); - if ((!player.worldObj.isDaytime()) || (rainWeather.booleanValue())) { - this.sunIsUp = false; - } - else { - this.sunIsUp = true; - } - if ((!player.worldObj.canBlockSeeTheSky((int) player.posX, (int) player.posY + 1, (int) player.posZ)) || (this.noSunWorld)) { - this.skyIsVisible = false; - } - else { - this.skyIsVisible = true; - } - } - - public static int tickRate() { - return 128; - } } diff --git a/src/main/resources/assets/emt/lang/en_US.lang b/src/main/resources/assets/emt/lang/en_US.lang index 66381fe..8ed5c7d 100644 --- a/src/main/resources/assets/emt/lang/en_US.lang +++ b/src/main/resources/assets/emt/lang/en_US.lang @@ -156,11 +156,11 @@ emt.text.Electric Goggles=You have found a way to detect auras using purely elec emt.rsname.Nanosuit Goggles of Revealing=Nanosuit Goggles of Revealing emt.tag.Nanosuit Goggles of Revealing=Top-tier eye protection -emt.text.Nanosuit Goggles of Revealing=You have discovered a way to incorporate your previous vis sensors to a Nanosuit Helmet without moving too much around. By infusing the nano helmet with magic, you will be able to use it to see Aura Nodes. During the magical process, the control circuits for the night vision feature are replaced with capacitors to absorb the excess magical energy and vis-sensing microchips. This will prevent you from turning off the night vision effect of the helmet. +emt.text.Nanosuit Goggles of Revealing=You have discovered a way to incorporate your previous vis sensors to a Nanosuit Helmet without moving too much around. By infusing the nano helmet with magic, you will be able to use it to see Aura Nodes. During the magical process, the control circuits for the night vision feature are replaced with capacitors to absorb the excess magical energy and vis-sensing microchips. emt.rsname.Quantum Goggles of Revealing=Quantum Goggles of Revealing emt.tag.Quantum Goggles of Revealing=Protection coupled with utility -emt.text.Quantum Goggles of Revealing=It took a lot of trial and error, but you have found a way to slip in vis detection sensors to a Quantum Helmet. By infusing the quantum helmet with magic, you will be able to use it to see Aura Nodes. During the design process, you had to replace several control circuits that involve night vision and automatic feeding with vis detecting circuitry and capacitors to absorb the excess magical energy. You find that using a Mining Laser to contain it can safely focus and direct the explosive pulse where the vision effect and the feeding unit of the helmet lie. Have fun getting force-fed energy. This will prevent you from turning off the night vision and feeding features. +emt.text.Quantum Goggles of Revealing=It took a lot of trial and error, but you have found a way to slip in vis detection sensors to a Quantum Helmet. By infusing the quantum helmet with magic, you will be able to use it to see Aura Nodes. During the design process, you had to replace several control circuits that involve night vision and automatic feeding with vis detecting circuitry and capacitors to absorb the excess magical energy. You find that using a Mining Laser to contain it can safely focus and direct the explosive pulse where the vision effect and the feeding unit of the helmet lie. Have fun getting force-fed energy. emt.rsname.Iron Omnitool=Iron Omnitool emt.tag.Iron Omnitool=Changing tools is for peasants @@ -248,7 +248,7 @@ emt.text.Compressed Solars=You have found a way to compress 9 mundane Solar Pane emt.rsname.Solar Helmet of Revealing=Solar Helmet of Revealing emt.tag.Solar Helmet of Revealing=The sunlight hurts my eyes -emt.text.Solar Helmet of Revealing=You now have a helmet that acts exactly like your quantum goggles of revealing, but can also recharge your chest armor! It generates 128 EU/t during the day, and nothing at night. +emt.text.Solar Helmet of Revealing=You now have a helmet that acts exactly like your quantum goggles of revealing, but can also recharge your chest armor! It generates 65536 EU during the day, and 4096 EU at night. emt.rsname.Diamond Chainsaw=Diamond Chainsaw emt.tag.Diamond Chainsaw=Harder, better, faster, stronger diff --git a/src/main/resources/assets/emt/lang/ru_RU.lang b/src/main/resources/assets/emt/lang/ru_RU.lang index c803d1e..eaa688c 100644 --- a/src/main/resources/assets/emt/lang/ru_RU.lang +++ b/src/main/resources/assets/emt/lang/ru_RU.lang @@ -155,11 +155,11 @@ emt.text.Electric Goggles=Вы обнаружили способ обнаруж emt.rsname.Nanosuit Goggles of Revealing=Нано-очки откровения emt.tag.Nanosuit Goggles of Revealing=Защита глаз высшего уровня -emt.text.Nanosuit Goggles of Revealing=Вы обнаружили способ добавления Ваших предыдущих датчиков Вис, в нано-шлем без особых усилий. Наполнив нано-шлем магией, Вы сможете увидеть узлы ауры. Во время магического процесса, микросхемы для функции ночного зрения заменились конденсаторами, чтобы поглощать избыточную магическую энергию и микрочипы датчиков Вис. Это избавит Вас от выключения эффекта ночного зрения. +emt.text.Nanosuit Goggles of Revealing=Вы обнаружили способ добавления Ваших предыдущих датчиков Вис, в нано-шлем без особых усилий. Наполнив нано-шлем магией, Вы сможете увидеть узлы ауры. Во время магического процесса, микросхемы для функции ночного зрения заменились конденсаторами, чтобы поглощать избыточную магическую энергию и микрочипы датчиков Вис. emt.rsname.Quantum Goggles of Revealing=Квантовые очки откровения emt.tag.Quantum Goggles of Revealing=Защита в сочетании с полезностью -emt.text.Quantum Goggles of Revealing=Методом проб и ошибок, Вы обнаружили способ добавления датчиков Вис в квантовой шлем. Наполнив квантовый шлем магией, Вы сможете увидеть узлы ауры. В процессе проектирования, Вам пришлось заменить несколько микросхем, которые включают ночное зрение, автоматическую подачу Вис и конденсаторы, чтобы поглощать избыточную магическую энергию. Вы обнаружили, что использование шахтёрского лазера для сбора магической энергии, может сосредоточить и направить взрывной импульс туда, где эффект зрения и подача шлема - лжёт. Удачи в получении лишней энергии. Это избавит Вас от выключения эффекта ночного зрения и функции подачи. +emt.text.Quantum Goggles of Revealing=Методом проб и ошибок, Вы обнаружили способ добавления датчиков Вис в квантовой шлем. Наполнив квантовый шлем магией, Вы сможете увидеть узлы ауры. В процессе проектирования, Вам пришлось заменить несколько микросхем, которые включают ночное зрение, автоматическую подачу Вис и конденсаторы, чтобы поглощать избыточную магическую энергию. Вы обнаружили, что использование шахтёрского лазера для сбора магической энергии, может сосредоточить и направить взрывной импульс туда, где эффект зрения и подача шлема - лжёт. Удачи в получении лишней энергии. emt.rsname.Iron Omnitool=Железный мультиинструмент emt.tag.Iron Omnitool=Смена инструментов для холопов @@ -247,7 +247,7 @@ emt.text.Compressed Solars=Вы обнаружили способ сжатия emt.rsname.Solar Helmet of Revealing=Солнечные очки откровения emt.tag.Solar Helmet of Revealing=Солнечный свет причиняет боль моим глазам! -emt.text.Solar Helmet of Revealing=Теперь у Вас есть шлем, который функционирует, как квантовые очки откровения, но он также может заряжать Вашу кирасу!За один день он генерирует 128 EU/тик, но не ночью. +emt.text.Solar Helmet of Revealing=Теперь у Вас есть шлем, который функционирует, как квантовые очки откровения, но он также может заряжать Вашу кирасу! За один день он генерирует 65536 EU, и 4096 EU ночью. emt.rsname.Diamond Chainsaw=Алмазная электропила emt.tag.Diamond Chainsaw=Выносливее, лучше, быстрее, сильнее