Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
Several fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bartimaeusnek committed Jan 11, 2021
1 parent a811bd4 commit d1ffbd2
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 28 deletions.
7 changes: 6 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ buildscript {
plugins {
idea
java
id("org.ajoberstar.grgit") version("3.1.1")
}

apply(plugin = "forge")
Expand Down Expand Up @@ -151,7 +152,7 @@ tasks.withType<Jar> {
// this will ensure that this task is redone when the versions change.
this.inputs.properties += "version" to project.version
this.inputs.properties += "mcversion" to project.minecraft.version
this.archiveBaseName.set("bartworks[${project.minecraft.version}]")
this.archiveBaseName.set("bartworks[${project.minecraft.version}]-[${getVersionAppendage()}]")

// replace stuff in mcmod.info, nothing else
this.filesMatching("/mcmod.info") {
Expand Down Expand Up @@ -203,4 +204,8 @@ artifacts {
this.archives(apiJar)
this.archives(sourcesJar)
this.archives(devJar)
}

fun getVersionAppendage() : String {
return org.ajoberstar.grgit.Grgit.open(mapOf("currentDir" to project.rootDir)).log().last().abbreviatedId
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#
majorUpdate=0
minorUpdate=5
buildNumber=14
buildNumber=15
apiVersion=11
ic2Version=2.2.828-experimental
applecoreVersion=1.7.10-3.1.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -61,12 +61,9 @@ public BW_MetaGenerated_Blocks(Material p_i45386_1_, Class<? extends TileEntity>
@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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,7 +57,7 @@ protected void doRegistrationStuff(Werkstoff w) {

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,25 +145,25 @@ public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int
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);
}
}
Expand All @@ -177,6 +177,14 @@ public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int
}
}

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);
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -835,4 +836,16 @@ else if (in.equals(OreDictNames.craftingAnvil.toString()))
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);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
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);
}

protected TT_Abstract_GT_Replacement_Coils(String aName) {
super(aName);
}

protected HeatingCoilLevel heatingCoilLevel = HeatingCoilLevel.None;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -164,22 +160,36 @@ public boolean addOutput(FluidStack aLiquid) {
.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;
Expand Down

0 comments on commit d1ffbd2

Please sign in to comment.