diff options
author | Alkalus <draknyte1@hotmail.com> | 2017-11-16 15:50:56 +1000 |
---|---|---|
committer | Alkalus <draknyte1@hotmail.com> | 2017-11-16 15:50:56 +1000 |
commit | 5144539962acc7d02248ed7075507b850044d877 (patch) | |
tree | 65ede90a22d833533ff80c4eee9a89b8d431bada /src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java | |
parent | c4963cab1c91ef09eb7b5694e8fa59ccb1023184 (diff) | |
download | GT5-Unofficial-5144539962acc7d02248ed7075507b850044d877.tar.gz GT5-Unofficial-5144539962acc7d02248ed7075507b850044d877.tar.bz2 GT5-Unofficial-5144539962acc7d02248ed7075507b850044d877.zip |
+ Added in annoying logging.
$ Fixed NPE when tickhandler tries to get null Tile entity.
% Tweaked Stored Energy and A/in/t for Wireless Charger.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java')
-rw-r--r-- | src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java index f4e53bc5dc..41ae1a911b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -37,6 +37,7 @@ public class ChargingHelper { //Called whenever the player is updated or ticked. @SubscribeEvent(priority = EventPriority.HIGHEST) public void onPlayerTick(LivingUpdateEvent event) { + try { if (event.entity != null && event.entityLiving != null){ if (event.entityLiving instanceof EntityPlayer){ EntityPlayer mPlayerMan = (EntityPlayer) event.entityLiving; @@ -133,6 +134,10 @@ public class ChargingHelper { } } } + } + catch (Throwable t){ + Utils.LOG_INFO("State of Wireless Charger changed in an invalid way, this prevented a crash."); + } } public static boolean addEntry(BlockPos mPos, GregtechMetaWirelessCharger mEntity){ @@ -256,14 +261,18 @@ public class ChargingHelper { for (ItemStack mTemp : mItems){ mItemSlot++; - Utils.LOG_INFO("Trying to Tick slot "+mItemSlot); + if (mTemp != null){ + Utils.LOG_INFO("Slot "+mItemSlot+" contains "+mTemp.getDisplayName()); + } //Is item Electrical if (isItemValid(mTemp)){ + Utils.LOG_INFO("1"); //Transfer Limit double mItemEuTLimit = ((IElectricItem) mTemp.getItem()).getTransferLimit(mTemp); //Check if Tile has more or equal EU to what can be transferred into the item. if (mEuStored >= mItemEuTLimit){ + Utils.LOG_INFO("2"); double mItemMaxCharge = ((IElectricItem) mTemp.getItem()).getMaxCharge(mTemp); double mitemCurrentCharge = ElectricItem.manager.getCharge(mTemp); @@ -273,7 +282,8 @@ public class ChargingHelper { } //Try get charge direct from NBT for GT and IC2 stacks - try { + try { + Utils.LOG_INFO("3"); if (mTemp.getItem() instanceof GT_MetaGenerated_Tool_01 || mTemp.getItem() instanceof GT_MetaGenerated_Item_01 || mTemp.getItem() instanceof GT_MetaGenerated_Item_02 @@ -310,6 +320,8 @@ public class ChargingHelper { else { mVoltageIncrease = mItemEuTLimit; } + + Utils.LOG_INFO("4"); int mMulti; if ((mitemCurrentCharge + (mVoltageIncrease*20)) <= (mItemMaxCharge - (mVoltageIncrease*20))){ @@ -324,12 +336,15 @@ public class ChargingHelper { else { mMulti = 1; } + Utils.LOG_INFO("5"); int mMultiVoltage = (int) (mMulti*mVoltageIncrease); if ((mitemCurrentCharge + mMultiVoltage) <= mItemMaxCharge){ + Utils.LOG_INFO("6"); if (GT_ModHandler.chargeElectricItem(mTemp, mMultiVoltage, mTier, true, false) == 0){ + Utils.LOG_INFO("6.5"); for (int i=0; i<mMulti;i++){ if (ElectricItem.manager.charge(mTemp, mVoltageIncrease, mTier, false, false) == 0){ continue; @@ -337,6 +352,7 @@ public class ChargingHelper { } } if (ElectricItem.manager.getCharge(mTemp) > mitemCurrentCharge){ + Utils.LOG_INFO("7"); mEntity.setEUVar((long) (mEuStored-(mVoltage*mMulti))); mEuStored = mEntity.getEUVar(); Utils.LOG_INFO("Charged "+mTemp.getDisplayName()+" | Slot: "+mItemSlot+" | EU Multiplier: "+mMulti+" | EU/t input: "+mVoltageIncrease+" | EU/t consumed by Tile: "+mVoltage+" | Item Max Charge: "+mItemMaxCharge+" | Item Start Charge: "+mitemCurrentCharge+" | Item New Charge"+ElectricItem.manager.getCharge(mTemp)); @@ -349,7 +365,7 @@ public class ChargingHelper { } else { if (mTemp != null){ - Utils.LOG_INFO("Found Non-Valid item."+mTemp.getDisplayName()); + Utils.LOG_INFO("Found Non-Valid item. "+mTemp.getDisplayName()); } } } |