use of gregtech.api.util.XSTR in project GregTech by GregTechCE.
the class SteamRecipeMapWorkableHandler method tryDoVenting.
protected void tryDoVenting() {
BlockPos machinePos = metaTileEntity.getPos();
BlockPos ventingBlockPos = machinePos.offset(ventingSide);
IBlockState blockOnPos = metaTileEntity.getWorld().getBlockState(ventingBlockPos);
if (blockOnPos.getCollisionBoundingBox(metaTileEntity.getWorld(), ventingBlockPos) == Block.NULL_AABB) {
metaTileEntity.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(ventingBlockPos), EntitySelectors.CAN_AI_TARGET).forEach(entity -> entity.attackEntityFrom(DamageSources.getHeatDamage(), 6.0f));
metaTileEntity.getWorld().spawnParticle(EnumParticleTypes.SMOKE_LARGE, machinePos.getX() - 0.5f + (new XSTR()).nextFloat(), machinePos.getY() - 0.5f + (new XSTR()).nextFloat(), machinePos.getZ() - 0.5f + (new XSTR()).nextFloat(), ventingSide.getFrontOffsetX() / 5.0, ventingSide.getFrontOffsetY() / 5.0, ventingSide.getFrontOffsetZ() / 5.0);
// TODO some good sound for venting
setNeedsVenting(false);
} else if (!ventingStuck) {
setVentingStuck(true);
}
}
use of gregtech.api.util.XSTR in project GregTech by GregTechCE.
the class GTWorldGenStone method generate.
protected final void generate(Random random, int chunkX, int chunkZ, World world, boolean shortcut, Predicate<BlockPos> allowGenerateAtCenter, ActionAtPos action) {
int size = this.minSize + random.nextInt(this.maxSize - this.minSize);
int step = size >> 3;
int centerX = (chunkX << 4) + random.nextInt(16);
int centerY = this.minY + random.nextInt(this.maxY - this.minY);
int centerZ = (chunkZ << 4) + random.nextInt(16);
if (!allowGenerateAtCenter.test(new BlockPos(centerX, centerY, centerZ)))
return;
float phi = 6.2831855f * random.nextFloat();
float cosPhi = MathHelper.cos(phi);
float sinPhi = MathHelper.sin(phi);
// float theta = (float) Math.acos(.5f * random.nextFloat());
float cosTheta = .5f * random.nextFloat();
float sinTheta = MathHelper.sqrt(1.0f - cosTheta * cosTheta);
float val08 = .5235988f * (1.0f + random.nextFloat());
float semiAxisA = size * MathHelper.cos(val08);
float semiAxisB = size * MathHelper.sin(val08);
float semiAxisC = size * (random.nextFloat() * .5f + .5f) * .5f;
float maxRange = Math.max(semiAxisA, Math.max(semiAxisB, semiAxisC)) + step;
float val17 = sinTheta * cosPhi;
float val18 = cosTheta * cosPhi;
float val19 = sinTheta * sinPhi;
float val20 = cosTheta * sinPhi;
int minX = MathHelper.floor(centerX + .5f - maxRange);
int maxX = MathHelper.ceil(centerX + .5f + maxRange) + 1;
int minZ = MathHelper.floor(centerZ + .5f - maxRange);
int maxZ = MathHelper.ceil(centerZ + .5f + maxRange) + 1;
int minY = MathHelper.floor(centerY + .5f - maxRange);
int maxY = MathHelper.ceil(centerY + .5f + maxRange) + 1;
float[] scales = new float[(step << 1) + 1];
float[][] vals1 = new float[8][(step << 1) + 1];
for (int i = 0; i < scales.length; i++) {
scales[i] = random.nextFloat();
float var = 6.2831855f * random.nextFloat();
vals1[0][i] = .8660254f + .1339746f * random.nextFloat();
vals1[1][i] = MathHelper.sqrt(1.0f - vals1[0][i] * vals1[0][i]);
vals1[2][i] = MathHelper.cos(var);
vals1[3][i] = MathHelper.sin(var);
vals1[4][i] = vals1[0][i] * vals1[2][i];
vals1[5][i] = vals1[0][i] * vals1[3][i];
vals1[6][i] = vals1[1][i] * vals1[2][i];
vals1[7][i] = vals1[1][i] * vals1[3][i];
}
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
Random rnd = new XSTR(WorldGenerator.getRandomSeed(world, centerX, centerZ));
for (int x = minX; x < maxX; x++) {
for (int z = minZ; z < maxZ; z++) {
for (int y = minY; y < maxY; y++) {
float var03 = x - centerX;
float var04 = z - centerZ;
float var05 = y - centerY;
float var06 = var03 * val17 + var04 * val18 + var05 * sinPhi;
float var07 = var04 * sinTheta - var03 * cosTheta;
float var08 = var05 * cosPhi - var03 * val19 - var04 * val20;
float r = 2.0f;
for (int i = 0; i < scales.length; i++) {
float var10 = var06 + (i << 1) - (step << 1);
float var11 = var10 * vals1[4][i] - var08 * vals1[6][i] + var07 * vals1[3][i];
float var12 = var07 * vals1[2][i] - var10 * vals1[5][i] + var08 * vals1[7][i];
float var13 = var10 * vals1[1][i] + var08 * vals1[0][i];
float var14 = scales[i] == 0.0f ? 0 : normSquare(var11 / semiAxisA / scales[i], var12 / semiAxisB / scales[i], var13 / semiAxisC / scales[i]);
if (var14 < r)
r = var14;
if (shortcut && r <= 1.0f) {
action.generate(pos.setPos(x, y, z), r, rnd);
break;
}
}
if (!shortcut && r <= 1.0f) {
action.generate(pos.setPos(x, y, z), r, rnd);
}
}
}
}
}
use of gregtech.api.util.XSTR in project GregTech by GregTechCE.
the class WorldGenerator method generate.
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
synchronized (this) {
if (!sorted) {
GregTechAPI.worldgenList.sort(GTWorldGen::compareTo);
sorted = true;
}
}
Random rnd = new XSTR();
Biome biome = world.getBiome(new BlockPos(chunkX << 4, 64, chunkZ << 4));
HashSet<ChunkPos> centers = new HashSet<>();
int maxRange = (GTWorldGenOreVein.getMaxOreVeinSize(world) + 15) >> 4;
if (maxRange > 0) {
for (int i = -maxRange; i <= maxRange; i++) {
for (int j = -maxRange; j <= maxRange; j++) {
centers.add(new ChunkPos(getVeinCenterCoordinate(chunkX + i), getVeinCenterCoordinate(chunkZ + j)));
}
}
centers.forEach(pos -> generateOreLayerAt(chunkX, chunkZ, pos.x, pos.z, world, biome, chunkGenerator, chunkProvider));
}
for (GTWorldGen worldgen : GregTechAPI.worldgenList) {
try {
worldgen.generate(rnd, chunkX, chunkZ, world, biome, chunkGenerator, chunkProvider);
} catch (Exception e) {
GTLog.logger.catching(e);
}
}
}
Aggregations