diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2018-05-29 16:34:22 +1000 |
---|---|---|
committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2018-05-29 16:34:22 +1000 |
commit | 272cd6156d1dc92985b613511b4cae62ef516bb1 (patch) | |
tree | 3c3a4502e5f57473a50171eae8eec676f9f74320 /src/Java | |
parent | 45c071b2ac73abc28671bbaa087dec075e4254c0 (diff) | |
download | GT5-Unofficial-272cd6156d1dc92985b613511b4cae62ef516bb1.tar.gz GT5-Unofficial-272cd6156d1dc92985b613511b4cae62ef516bb1.tar.bz2 GT5-Unofficial-272cd6156d1dc92985b613511b4cae62ef516bb1.zip |
% Changed max thread life to 300 seconds.
$ More thread safety.
- Removed useless EIO tooltip variables.
Diffstat (limited to 'src/Java')
4 files changed, 16 insertions, 57 deletions
diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index a6e4589159..7d4f20aa56 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -161,13 +161,13 @@ public class GTplusplus implements ActionListener { } @EventHandler - public void serverStarting(final FMLServerStartingEvent event) { + public synchronized void serverStarting(final FMLServerStartingEvent event) { event.registerServerCommand(new CommandMath()); tryPatchTurbineTextures(); } @Mod.EventHandler - public void serverStopping(final FMLServerStoppingEvent event) { + public synchronized void serverStopping(final FMLServerStoppingEvent event) { //Chunkload Handler if (ChunkManager.mChunkLoaderManagerMap.size() > 0) { Logger.INFO("Clearing Chunk Loaders."); @@ -178,7 +178,6 @@ public class GTplusplus implements ActionListener { for (GregtechBufferThread i : GregtechBufferThread.mBufferThreadAllocation.values()) { i.destroy(); } - GregtechBufferThread.mBufferThreadAllocation.clear(); } } diff --git a/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java b/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java index d04af8252b..6d50f64e6d 100644 --- a/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java +++ b/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java @@ -18,14 +18,6 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent; public class HandlerTooltip_EIO { 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; @@ -41,16 +33,13 @@ public class HandlerTooltip_EIO { oMainClass = Class.forName("crazypants.enderio.EnderIO"); oIngotClass = Class.forName("crazypants.enderio.material.ItemAlloy"); if (oMainClass != null && oIngotClass != null){ - Field oAlloyField = oMainClass.getDeclaredField("itemAlloy"); oAlloyField.setAccessible(true); Object oAlloy = oAlloyField.get(oMainClass); - if (oAlloy != null){ if (oIngotClass.isInstance(oAlloy) || Item.class.isInstance(oAlloy)){ mIngot = (Item) oAlloy; } - } } } @@ -62,36 +51,6 @@ public class HandlerTooltip_EIO { //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 (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){ diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ThreadedBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ThreadedBuffer.java index 8dc0a8c2cf..855b856f49 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ThreadedBuffer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_ThreadedBuffer.java @@ -21,6 +21,7 @@ public abstract class GT_MetaTileEntity_ThreadedBuffer extends GT_MetaTileEntity protected GregtechBufferThread mLogicThread; protected BlockPos mPos; public final ItemStack[] mInventorySynchro; + public int mThreadTimeLeft = 0; public GT_MetaTileEntity_ThreadedBuffer(final int aID, final String aName, final String aNameRegional, final int aTier, final int aInvSlotCount, final String aDescription) { @@ -308,6 +309,7 @@ public abstract class GT_MetaTileEntity_ThreadedBuffer extends GT_MetaTileEntity } if (mLogicThread!= null) { getLogicThread().onPostTick(aBaseMetaTileEntity, aTimer, this); + this.mThreadTimeLeft = this.mLogicThread.getTimeLeft(); } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java b/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java index 47c53d18f1..cf477b0889 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/objects/GregtechBufferThread.java @@ -1,8 +1,8 @@ package gtPlusPlus.xmod.gregtech.api.objects; -import java.util.HashMap; import java.util.List; -import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; @@ -18,9 +18,10 @@ import gtPlusPlus.xmod.gregtech.common.tileentities.automation.GT_MetaTileEntity public class GregtechBufferThread extends Thread { - public static final Map<String, GregtechBufferThread> mBufferThreadAllocation = new HashMap<String, GregtechBufferThread>(); + public static final ConcurrentMap<String, GregtechBufferThread> mBufferThreadAllocation = new ConcurrentHashMap<String, GregtechBufferThread>(); private final BlockPos mBlockPos; - private int mLifeCycleTime = 300; + private final int mMaxLife = 300; + private int mLifeCycleTime = mMaxLife; private final String mID; public static synchronized final GregtechBufferThread getBufferThread(BlockPos pos) { @@ -51,11 +52,12 @@ public class GregtechBufferThread extends Thread { Logger.INFO("[SB] Created a SuperBuffer Thread for dimension "+mID+"."); } } + + public synchronized int getTimeLeft() { + return this.mLifeCycleTime; + } public synchronized void fillStacksIntoFirstSlots(GT_MetaTileEntity_ThreadedChestBuffer mBuffer) { - if (mLifeCycleTime < (Short.MAX_VALUE-10)){ - mLifeCycleTime += 10; - } for (int i = 0; i < mBuffer.mInventorySynchro.length - 1; ++i) { for (int j = i + 1; j < mBuffer.mInventorySynchro.length - 1; ++j) { if (mBuffer.mInventorySynchro[j] != null && (mBuffer.mInventorySynchro[i] == null @@ -68,9 +70,6 @@ public class GregtechBufferThread extends Thread { } public synchronized boolean moveItems(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer, GT_MetaTileEntity_ThreadedBuffer mBuffer) { - if (mLifeCycleTime < (Short.MAX_VALUE-10)){ - mLifeCycleTime += 10; - } final byte mTargetStackSize = (byte) mBuffer.mTargetStackSize; final int tCost = GT_Utility.moveOneItemStack((Object) aBaseMetaTileEntity, (Object) aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), @@ -91,7 +90,7 @@ public class GregtechBufferThread extends Thread { && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified() || aTimer % 200L == 0L || mBuffer.mSuccess > 0)) { --mBuffer.mSuccess; - if (mLifeCycleTime < (Short.MAX_VALUE-1)){ + if (mLifeCycleTime < (mMaxLife-1)){ mLifeCycleTime += 1; } //Logger.INFO("Ticking SB @ "+mBuffer.getLogicThread().mBlockPos.getUniqueIdentifier() + " | Time Left: "+mLifeCycleTime); @@ -192,8 +191,8 @@ public class GregtechBufferThread extends Thread { mLifeCycleTime = 0; } //Prevent Overflows - if (mLifeCycleTime > Short.MAX_VALUE) { - mLifeCycleTime = Short.MAX_VALUE; + if (mLifeCycleTime > mMaxLife) { + mLifeCycleTime = mMaxLife; } try { sleep(1000); |