diff options
| author | NotAPenguin <michiel.vandeginste@gmail.com> | 2024-09-02 23:17:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-02 23:17:17 +0200 |
| commit | 1b820de08a05070909a267e17f033fcf58ac8710 (patch) | |
| tree | 02831a025986a06b20f87e5bcc69d1e0c639a342 /src/main/java/galacticgreg/generators | |
| parent | afd3fd92b6a6ab9ab0d0dc3214e6bc8ff7a86c9b (diff) | |
| download | GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.tar.gz GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.tar.bz2 GT5-Unofficial-1b820de08a05070909a267e17f033fcf58ac8710.zip | |
The Great Renaming (#3014)
* move kekztech to a single root dir
* move detrav to a single root dir
* move gtnh-lanthanides to a single root dir
* move tectech and delete some gross reflection in gt++
* remove more reflection inside gt5u
* delete more reflection in gt++
* fix imports
* move bartworks and bwcrossmod
* fix proxies
* move galactigreg and ggfab
* move gtneioreplugin
* try to fix gt++ bee loader
* apply the rename rules to BW
* apply rename rules to bwcrossmod
* apply rename rules to detrav scanner mod
* apply rename rules to galacticgreg
* apply rename rules to ggfab
* apply rename rules to goodgenerator
* apply rename rules to gtnh-lanthanides
* apply rename rules to gt++
* apply rename rules to kekztech
* apply rename rules to kubatech
* apply rename rules to tectech
* apply rename rules to gt
apply the rename rules to gt
* fix tt import
* fix mui hopefully
* fix coremod except intergalactic
* rename assline recipe class
* fix a class name i stumbled on
* rename StructureUtility to GTStructureUtility to prevent conflict with structurelib
* temporary rename of GTTooltipDataCache to old name
* fix gt client/server proxy names
Diffstat (limited to 'src/main/java/galacticgreg/generators')
| -rw-r--r-- | src/main/java/galacticgreg/generators/GenEllipsoid.java | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/src/main/java/galacticgreg/generators/GenEllipsoid.java b/src/main/java/galacticgreg/generators/GenEllipsoid.java new file mode 100644 index 0000000000..432260a696 --- /dev/null +++ b/src/main/java/galacticgreg/generators/GenEllipsoid.java @@ -0,0 +1,126 @@ +package galacticgreg.generators; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; + +import galacticgreg.api.Enums.SpaceObjectType; +import galacticgreg.api.Enums.TargetBlockPosition; +import galacticgreg.api.ISpaceObjectGenerator; +import galacticgreg.api.StructureInformation; + +/** + * Simple ellipsoid-generator. Based on the formular created by Chrysator. Thanks for the help! + * + * Generates a simple ellipsoid with dynamic rotation, random size-values, random noise for the surface, etc. Can + * probably be tweaked even more, but works for now... + */ +public class GenEllipsoid implements ISpaceObjectGenerator { + + private Vec3 _mEllipsoidCenter; + private Random _mRandom; + private List<StructureInformation> _mStructure; + + private double _mCoreDensity = 0.7D; + private double _mSineFactor = 0.05D; + private float _mRandomInfluence; + private float _mRandomAngleX; + private float _mRandomAngleY; + private float _mRandomAngleZ; + + private int _mSizeA; + private int _mSizeB; + private int _mSizeC; + + public GenEllipsoid() { + reset(); + } + + @Override + public SpaceObjectType getType() { + return SpaceObjectType.OreAsteroid; + } + + @Override + public void randomize(int pSizeMin, int pSizeMax) { + _mRandom = new Random(System.currentTimeMillis()); + _mRandomAngleX = (float) (_mRandom.nextFloat() * Math.PI); + _mRandomAngleY = (float) (_mRandom.nextFloat() * Math.PI); + _mRandomAngleZ = (float) (_mRandom.nextFloat() * Math.PI); + + _mRandomInfluence = _mRandom.nextFloat(); + + _mSizeA = pSizeMin + _mRandom.nextInt(pSizeMax - pSizeMin) + 10; + _mSizeB = pSizeMin + _mRandom.nextInt(pSizeMax - pSizeMin) + 10; + _mSizeC = pSizeMin + _mRandom.nextInt(pSizeMax - pSizeMin) + 10; + } + + @Override + public void setCenterPoint(int pX, int pY, int pZ) { + _mEllipsoidCenter = Vec3.createVectorHelper(pX, pY, pZ); + } + + @Override + public void setCenterPoint(Vec3 pCenter) { + _mEllipsoidCenter = pCenter; + } + + @Override + public Vec3 getCenterPoint() { + return _mEllipsoidCenter; + } + + @Override + public List<StructureInformation> getStructure() { + return _mStructure; + } + + @Override + public void calculate() { + int Xmin = (int) (_mEllipsoidCenter.xCoord - _mSizeA); + int Xmax = (int) (_mEllipsoidCenter.xCoord + _mSizeA); + int Ymin = (int) (_mEllipsoidCenter.yCoord - _mSizeB); + int Ymax = (int) (_mEllipsoidCenter.yCoord + _mSizeB); + int Zmin = (int) (_mEllipsoidCenter.zCoord - _mSizeC); + int Zmax = (int) (_mEllipsoidCenter.zCoord + _mSizeC); + + for (int iX = Xmin; iX <= Xmax; iX++) { + for (int iY = Ymin; iY <= Ymax; iY++) { + for (int iZ = Zmin; iZ <= Zmax; iZ++) { + double tmpX = Math.pow(_mEllipsoidCenter.xCoord - iX, 2) / Math.pow(_mSizeA, 2); + double tmpY = Math.pow(_mEllipsoidCenter.yCoord - iY, 2) / Math.pow(_mSizeB, 2); + double tmpZ = Math.pow(_mEllipsoidCenter.zCoord - iZ, 2) / Math.pow(_mSizeC, 2); + double val = (tmpX + tmpY + tmpZ); + + Vec3 tPoint = Vec3.createVectorHelper(iX, iY, iZ); + tPoint.rotateAroundX(_mRandomAngleX); + tPoint.rotateAroundY(_mRandomAngleY); + tPoint.rotateAroundZ(_mRandomAngleZ); + + TargetBlockPosition tbp = TargetBlockPosition.Invalid; + + if (val <= 0.01D) tbp = TargetBlockPosition.AsteroidInnerCore; + + else if (val > 0.01D && val < _mCoreDensity) tbp = TargetBlockPosition.AsteroidCore; + + else if (val >= _mCoreDensity && val <= (1.0D + - (_mSineFactor * MathHelper.sin((iZ + iX + iY - _mRandom.nextFloat() * _mRandomInfluence))))) + tbp = TargetBlockPosition.AsteroidShell; + + if (tbp != TargetBlockPosition.Invalid) + _mStructure.add(new StructureInformation(Vec3.createVectorHelper(iX, iY, iZ), tbp)); + + } + } + } + } + + @Override + public void reset() { + _mStructure = new ArrayList<>(); + _mEllipsoidCenter = Vec3.createVectorHelper(0, 0, 0); + } +} |
