diff options
author | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2021-01-11 17:44:17 +0100 |
---|---|---|
committer | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2021-01-11 17:44:17 +0100 |
commit | aa72a003f730350172e60ec556e68ebc5de41fc1 (patch) | |
tree | fbec57129459a1a49790783fa855f876cb5ca401 /src/main | |
parent | bfa9ed104cca51ecfdebd73cef4e911fdcf257e8 (diff) | |
download | GT5-Unofficial-aa72a003f730350172e60ec556e68ebc5de41fc1.tar.gz GT5-Unofficial-aa72a003f730350172e60ec556e68ebc5de41fc1.tar.bz2 GT5-Unofficial-aa72a003f730350172e60ec556e68ebc5de41fc1.zip |
Several fixes
Former-commit-id: 85ba0f632541272c8a3072747cb2a3a23d2821ce
Diffstat (limited to 'src/main')
6 files changed, 57 insertions, 26 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java index 0d6bfbc9d3..8a2143dba7 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java @@ -22,9 +22,9 @@ package com.github.bartimaeusnek.bartworks.system.material; -import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.client.renderer.BW_Renderer_Block_Ores; import com.github.bartimaeusnek.bartworks.common.blocks.BW_TileEntityContainer; +import com.github.bartimaeusnek.bartworks.util.BW_Util; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.OrePrefixes; @@ -61,12 +61,9 @@ public abstract class BW_MetaGenerated_Blocks extends BW_TileEntityContainer { @Override public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { super.onBlockAdded(aWorld, aX, aY, aZ); - try { - //TODO: Unsleep this, is here because TE isnt set yet. - Thread.sleep(1); - } catch (InterruptedException e) { - MainMod.LOGGER.catching(e); - } + //Waste some time to allow the TE to be set, do not use thread sleep here, it doesnt allow for nanoseconds. + //This will just waste a few cpu cycles to allow the TE to be set + BW_Util.shortSleep(0); } @SideOnly(Side.CLIENT) diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java index 37c1da6c8d..1f86b274af 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java @@ -22,6 +22,7 @@ package com.github.bartimaeusnek.bartworks.system.material; +import com.github.bartimaeusnek.bartworks.util.MathUtils; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_ModHandler; @@ -56,7 +57,7 @@ public class BW_MetaGenerated_Ores extends BW_MetaGenerated_Blocks { public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean air, Block block, int[] aBlockMeta) { if (!air) { - aY = Math.min(aWorld.getActualHeight(), Math.max(aY, 1)); + aY = MathUtils.clamp(aY,1, aWorld.getActualHeight()); } Block tBlock = aWorld.getBlock(aX, aY, aZ); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_OreLayer.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_OreLayer.java index 2a29fe2855..aa1023c9ba 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_OreLayer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_OreLayer.java @@ -145,25 +145,25 @@ public abstract class BW_OreLayer extends GT_Worldgen { int i; if (this.mSecondaryMeta > 0) { for (i = tMinY - 1; i < tMinY + 2; ++i) { - if (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 || aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0) { + if (shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ)) { wasPlaced = this.setOreBlock(aWorld, tX, i, tZ, this.mSecondaryMeta, false); } } } - if (this.mBetweenMeta > 0 && (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 || aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0)) { + if (this.mBetweenMeta > 0 && shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ)) { wasPlaced = this.setOreBlock(aWorld, tX, tMinY + 2 + aRandom.nextInt(2), tZ, this.mBetweenMeta, false); } if (this.mPrimaryMeta > 0) { for (i = tMinY + 3; i < tMinY + 6; ++i) { - if (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 || aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0) { + if (shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ)) { wasPlaced = this.setOreBlock(aWorld, tX, i, tZ, this.mPrimaryMeta, false); } } } - if (this.mSporadicMeta > 0 && (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 || aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0)) { + if (this.mSporadicMeta > 0 && (shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ))) { wasPlaced = this.setOreBlock(aWorld, tX, tMinY - 1 + aRandom.nextInt(7), tZ, this.mSporadicMeta, false); } } @@ -177,6 +177,14 @@ public abstract class BW_OreLayer extends GT_Worldgen { } } + private boolean shouldPlace(Random aRandom, int cX, int eX, int tX, int cZ, int eZ, int tZ) { + if (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0) + return true; + if (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0) + return true; + return false; + } + public boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean isSmallOre) { //security stuff to prevent crashes with 2 TileEntites on the same Spot TileEntity te = aWorld.getTileEntity(aX,aY,aZ); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java index 21790bfe41..cc0c56214e 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java @@ -23,6 +23,7 @@ package com.github.bartimaeusnek.bartworks.util; import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; +import com.github.bartimaeusnek.bartworks.MainMod; import gregtech.api.enums.Materials; import gregtech.api.enums.OreDictNames; import gregtech.api.enums.ToolDictNames; @@ -835,4 +836,16 @@ public class BW_Util { return new GT_Shaped_Recipe(GT_Utility.copy(aResult), aDismantleable, aRemovable, aKeepNBT, aEnchantmentsAdded, aEnchantmentLevelsAdded, aRecipe).setMirrored(aMirrored); } + public static void shortSleep(long nanos) { + try { + long start = System.nanoTime(); + long end; + do { + end = System.nanoTime(); + } while(start + nanos >= end); + } catch (Exception e) { + MainMod.LOGGER.catching(e); + } + } + }
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_Abstract_GT_Replacement_Coils.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_Abstract_GT_Replacement_Coils.java index 868d432eb3..05f573b690 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_Abstract_GT_Replacement_Coils.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_Abstract_GT_Replacement_Coils.java @@ -4,6 +4,7 @@ import com.github.bartimaeusnek.crossmod.tectech.helper.IHasCoils; import gregtech.api.enums.HeatingCoilLevel; public abstract class TT_Abstract_GT_Replacement_Coils extends TT_Abstract_GT_Replacement implements IHasCoils { + protected TT_Abstract_GT_Replacement_Coils(int newId, String aName, String aNameRegional) { super(newId, aName, aNameRegional); } @@ -11,6 +12,7 @@ public abstract class TT_Abstract_GT_Replacement_Coils extends TT_Abstract_GT_Re protected TT_Abstract_GT_Replacement_Coils(String aName) { super(aName); } + protected HeatingCoilLevel heatingCoilLevel = HeatingCoilLevel.None; @Override diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_ElectronicBlastFurnace.java b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_ElectronicBlastFurnace.java index f2ee015f50..ad1932f3af 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_ElectronicBlastFurnace.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/tectech/tileentites/multi/GT_Replacement/TT_ElectronicBlastFurnace.java @@ -23,12 +23,8 @@ package com.github.bartimaeusnek.crossmod.tectech.tileentites.multi.GT_Replacement; import com.github.bartimaeusnek.crossmod.tectech.helper.CoilAdder; -import com.github.bartimaeusnek.crossmod.tectech.helper.IHasCoils; -import com.github.technus.tectech.mechanics.constructable.IConstructable; import com.github.technus.tectech.mechanics.structure.IStructureDefinition; import com.github.technus.tectech.mechanics.structure.StructureDefinition; -import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti; -import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; import com.google.common.collect.ImmutableSet; @@ -164,22 +160,36 @@ public class TT_ElectronicBlastFurnace extends TT_Abstract_GT_Replacement_Coils .findFirst() .map(tHatch -> 100 - tHatch.calculatePollutionReduction(100)) .orElse(0) + 5) / 100; + for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { + if ((isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid) + ? !tHatch.outputsSteam() + : !tHatch.outputsLiquids()) + || tHatch.getBaseMetaTileEntity().getYCoord() <= this.getBaseMetaTileEntity().getYCoord() + || canNotFillOutput(tHatch, tLiquid)) + continue; + return true; + } + } else { + for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { + if ((isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid) + ? !tHatch.outputsSteam() + : !tHatch.outputsLiquids()) + || tHatch.getBaseMetaTileEntity().getYCoord() > this.getBaseMetaTileEntity().getYCoord() + || canNotFillOutput(tHatch, tLiquid)) + continue; + return true; + } } + return false; + } - for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { - if ( - (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid) - ? !tHatch.outputsSteam() - : !tHatch.outputsLiquids()) - || tHatch.getBaseMetaTileEntity().getYCoord() <= this.getBaseMetaTileEntity().getYCoord()) - continue; + private boolean canNotFillOutput(GT_MetaTileEntity_Hatch_Output tHatch, FluidStack tLiquid){ int tAmount = tHatch.fill(tLiquid, false); if (tAmount >= tLiquid.amount) - return tHatch.fill(tLiquid, true) >= tLiquid.amount; + return tHatch.fill(tLiquid, true) < tLiquid.amount; else if (tAmount > 0) tLiquid.amount = tLiquid.amount - tHatch.fill(tLiquid, true); - } - return false; + return true; } private static final int pollutionPerTick = 20; |