aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/eio/handler
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2018-05-29 16:22:10 +1000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2018-05-29 16:22:10 +1000
commit45c071b2ac73abc28671bbaa087dec075e4254c0 (patch)
tree86ffb289dab9caf41b1887559632bba9b2dfa13f /src/Java/gtPlusPlus/xmod/eio/handler
parentaaed15d6c833f634b785cad80913e8cd691cd88c (diff)
downloadGT5-Unofficial-45c071b2ac73abc28671bbaa087dec075e4254c0.tar.gz
GT5-Unofficial-45c071b2ac73abc28671bbaa087dec075e4254c0.tar.bz2
GT5-Unofficial-45c071b2ac73abc28671bbaa087dec075e4254c0.zip
$ Reduced cpu usage in EIO tooltip handler.
$ Made GTPP clean up any left-over threads when the server shuts down (Mostly for SSP memory leaks). $ Made each buffer get a unique thread. Thread life reduced greatly and capped out at 32k seconds.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/eio/handler')
-rw-r--r--src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java146
1 files changed, 71 insertions, 75 deletions
diff --git a/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java b/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java
index 788e4d6d9f..d04af8252b 100644
--- a/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java
+++ b/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java
@@ -17,15 +17,17 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent;
public class HandlerTooltip_EIO {
- private static volatile Item mIngot;
- private static volatile ItemStack mPulsatingIron;
- private static volatile ItemStack mConductiveIron;
- private static volatile ItemStack mRedstoneAlloy;
- private static volatile ItemStack mElectricalSteel;
- private static volatile ItemStack mEnergeticAlloy;
- private static volatile ItemStack mVibrantAlloy;
- private static volatile ItemStack mSoularium;
- private static volatile ItemStack mDarkIron;
+ private static Item mIngot;
+ private static ItemStack mPulsatingIron;
+ private static ItemStack mConductiveIron;
+ private static ItemStack mRedstoneAlloy;
+ private static ItemStack mElectricalSteel;
+ private static ItemStack mEnergeticAlloy;
+ private static ItemStack mVibrantAlloy;
+ private static ItemStack mSoularium;
+ private static ItemStack mDarkIron;
+ Class oMainClass;
+ Class oIngotClass;
@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent event){
@@ -36,8 +38,8 @@ public class HandlerTooltip_EIO {
//If it is, reflect in.
if (mIngot == null){
try {
- Class<?> oMainClass = Class.forName("crazypants.enderio.EnderIO");
- Class<?> oIngotClass = Class.forName("crazypants.enderio.material.ItemAlloy");
+ oMainClass = Class.forName("crazypants.enderio.EnderIO");
+ oIngotClass = Class.forName("crazypants.enderio.material.ItemAlloy");
if (oMainClass != null && oIngotClass != null){
Field oAlloyField = oMainClass.getDeclaredField("itemAlloy");
@@ -56,77 +58,71 @@ public class HandlerTooltip_EIO {
}
}
- try {
- if (mIngot != null){
- //If the Item is an instance of ItemAlloy.class then proceed
- if (Class.forName("crazypants.enderio.material.ItemAlloy").isInstance(event.itemStack.getItem()) || event.itemStack.getUnlocalizedName().toLowerCase().contains("item.itemAlloy")){
+ if (mIngot != null){
+ //If the Item is an instance of ItemAlloy.class then proceed
+ if (event.itemStack.getItem() == mIngot || oIngotClass.isInstance(event.itemStack.getItem()) || event.itemStack.getUnlocalizedName().toLowerCase().contains("item.itemAlloy")){
- //If EIO Item Is not Null, see if the ItemStacks for the ingots are null
- //if they stacks are null, set the stack using the item set via reflection.
- //The meta data is based on the oridinals of the materials in the EIO enum.
+ //If EIO Item Is not Null, see if the ItemStacks for the ingots are null
+ //if they stacks are null, set the stack using the item set via reflection.
+ //The meta data is based on the oridinals of the materials in the EIO enum.
- if (mElectricalSteel == null){
- mElectricalSteel = ItemUtils.simpleMetaStack(mIngot, 0, 1);
- }
- if (mEnergeticAlloy == null){
- mEnergeticAlloy = ItemUtils.simpleMetaStack(mIngot, 1, 1);
- }
- if (mVibrantAlloy == null){
- mVibrantAlloy = ItemUtils.simpleMetaStack(mIngot, 2, 1);
- }
- if (mRedstoneAlloy == null){
- mRedstoneAlloy = ItemUtils.simpleMetaStack(mIngot, 3, 1);
- }
- if (mConductiveIron == null){
- mConductiveIron = ItemUtils.simpleMetaStack(mIngot, 4, 1);
- }
- if (mPulsatingIron == null){
- mPulsatingIron = ItemUtils.simpleMetaStack(mIngot, 5, 1);
- }
- if (mDarkIron == null){
- mDarkIron = ItemUtils.simpleMetaStack(mIngot, 6, 1);
- }
- if (mSoularium == null){
- mSoularium = ItemUtils.simpleMetaStack(mIngot, 7, 1);
- }
+ if (mElectricalSteel == null){
+ mElectricalSteel = ItemUtils.simpleMetaStack(mIngot, 0, 1);
+ }
+ if (mEnergeticAlloy == null){
+ mEnergeticAlloy = ItemUtils.simpleMetaStack(mIngot, 1, 1);
+ }
+ if (mVibrantAlloy == null){
+ mVibrantAlloy = ItemUtils.simpleMetaStack(mIngot, 2, 1);
+ }
+ if (mRedstoneAlloy == null){
+ mRedstoneAlloy = ItemUtils.simpleMetaStack(mIngot, 3, 1);
+ }
+ if (mConductiveIron == null){
+ mConductiveIron = ItemUtils.simpleMetaStack(mIngot, 4, 1);
+ }
+ if (mPulsatingIron == null){
+ mPulsatingIron = ItemUtils.simpleMetaStack(mIngot, 5, 1);
+ }
+ if (mDarkIron == null){
+ mDarkIron = ItemUtils.simpleMetaStack(mIngot, 6, 1);
+ }
+ if (mSoularium == null){
+ mSoularium = ItemUtils.simpleMetaStack(mIngot, 7, 1);
+ }
- //If stacks match, add a tooltip.
- if (mIngot != null){
- if (event.itemStack.getItem() == mIngot){
- if (event.itemStack.getItemDamage() == 0){
- event.toolTip.add(MaterialEIO.ELECTRICAL_STEEL.vChemicalFormula);
- }
- else if (event.itemStack.getItemDamage() == 1){
- event.toolTip.add(MaterialEIO.ENERGETIC_ALLOY.vChemicalFormula);
- }
- else if (event.itemStack.getItemDamage() == 2){
- event.toolTip.add(MaterialEIO.VIBRANT_ALLOY.vChemicalFormula);
- }
- else if (event.itemStack.getItemDamage() == 3){
- event.toolTip.add(MaterialEIO.REDSTONE_ALLOY.vChemicalFormula);
- }
- else if (event.itemStack.getItemDamage() == 4){
- event.toolTip.add(MaterialEIO.CONDUCTIVE_IRON.vChemicalFormula);
- }
- else if (event.itemStack.getItemDamage() == 5){
- event.toolTip.add(MaterialEIO.PULSATING_IRON.vChemicalFormula);
- }
- else if (event.itemStack.getItemDamage() == 6){
- event.toolTip.add(Materials.DarkSteel.mChemicalFormula);
- }
- else if (event.itemStack.getItemDamage() == 7){
- event.toolTip.add(MaterialEIO.SOULARIUM.vChemicalFormula);
- }
+ //If stacks match, add a tooltip.
+ if (mIngot != null){
+ if (event.itemStack.getItem() == mIngot){
+ if (event.itemStack.getItemDamage() == 0){
+ event.toolTip.add(MaterialEIO.ELECTRICAL_STEEL.vChemicalFormula);
}
- }
- }
+ else if (event.itemStack.getItemDamage() == 1){
+ event.toolTip.add(MaterialEIO.ENERGETIC_ALLOY.vChemicalFormula);
+ }
+ else if (event.itemStack.getItemDamage() == 2){
+ event.toolTip.add(MaterialEIO.VIBRANT_ALLOY.vChemicalFormula);
+ }
+ else if (event.itemStack.getItemDamage() == 3){
+ event.toolTip.add(MaterialEIO.REDSTONE_ALLOY.vChemicalFormula);
+ }
+ else if (event.itemStack.getItemDamage() == 4){
+ event.toolTip.add(MaterialEIO.CONDUCTIVE_IRON.vChemicalFormula);
+ }
+ else if (event.itemStack.getItemDamage() == 5){
+ event.toolTip.add(MaterialEIO.PULSATING_IRON.vChemicalFormula);
+ }
+ else if (event.itemStack.getItemDamage() == 6){
+ event.toolTip.add(Materials.DarkSteel.mChemicalFormula);
+ }
+ else if (event.itemStack.getItemDamage() == 7){
+ event.toolTip.add(MaterialEIO.SOULARIUM.vChemicalFormula);
+ }
+ }
+ }
}
}
- catch (ClassNotFoundException e) {
- }
}
-
}
-
}