use of net.minecraft.core.BlockPos.MutableBlockPos in project EdenRing by paulevsGitch.
the class DepthScatterFeature method place.
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featurePlaceContext) {
Random random = featurePlaceContext.random();
BlockPos center = featurePlaceContext.origin();
WorldGenLevel level = featurePlaceContext.level();
int posX = center.getX() & 0xFFFFFFF0;
int posZ = center.getZ() & 0xFFFFFFF0;
MutableBlockPos pos = new MutableBlockPos();
int iterations = MHelper.randRange(minCount, maxCount, random);
for (int n = 0; n < iterations; n++) {
int wx = posX | random.nextInt(16);
int wz = posZ | random.nextInt(16);
int wy = random.nextInt(256);
int radius = MHelper.randRange(minRadius, maxRadius, random);
int count = (int) (radius * radius * MHelper.randRange(0.7F, 2F, random));
float multiplier = radius / 3.0F;
for (int i = 0; i < count; i++) {
int px = wx + Mth.floor(Mth.clamp(random.nextGaussian() * multiplier, -radius, radius));
int py = wy + Mth.floor(Mth.clamp(random.nextGaussian() * multiplier, -radius, radius));
int pz = wz + Mth.floor(Mth.clamp(random.nextGaussian() * multiplier, -radius, radius));
pos.set(px, py, pz);
BlockState state = level.getBlockState(pos);
for (Block b : scatterIn) {
if (state.is(b)) {
BlocksHelper.setWithoutUpdate(level, pos, block);
break;
}
}
}
}
return true;
}
use of net.minecraft.core.BlockPos.MutableBlockPos in project EdenRing by paulevsGitch.
the class FloorScatterFeature method place.
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featurePlaceContext) {
Random random = featurePlaceContext.random();
BlockPos center = featurePlaceContext.origin();
WorldGenLevel level = featurePlaceContext.level();
MutableBlockPos pos = new MutableBlockPos();
int count = MHelper.randRange(100, 200, random);
for (int i = 0; i < count; i++) {
int px = center.getX() + Mth.floor(Mth.clamp(random.nextGaussian() * 2, -8, 8));
int py = center.getY() + Mth.floor(Mth.clamp(random.nextGaussian() * 2, -8, 8));
int pz = center.getZ() + Mth.floor(Mth.clamp(random.nextGaussian() * 2, -8, 8));
pos.set(px, py, pz);
for (Block floor : floors) {
if (level.getBlockState(pos).is(floor) && (!checkAir || level.getBlockState(pos.above()).isAir())) {
BlocksHelper.setWithoutUpdate(level, pos, block);
break;
}
}
}
return true;
}
use of net.minecraft.core.BlockPos.MutableBlockPos in project EdenRing by paulevsGitch.
the class GravityController method getGraviliteMultiplier.
public static double getGraviliteMultiplier(Entity entity) {
MutableBlockPos pos = entity.blockPosition().mutable();
int dist = 8;
for (int i = 0; i < 8; i++) {
if (entity.level.getBlockState(pos).is(EdenBlocks.GRAVILITE_BLOCK)) {
dist = i;
break;
}
pos.setY(pos.getY() - 1);
}
if (dist == 8) {
return 1.0;
}
float delta = Mth.clamp((dist + (float) (entity.getY() - (int) entity.getY())) / 8F, 0, 1);
return Mth.lerp(delta, 0.1, 1.0);
}
use of net.minecraft.core.BlockPos.MutableBlockPos in project EdenRing by paulevsGitch.
the class GravityController method getCompressorMultiplier.
public static double getCompressorMultiplier(Entity entity) {
MutableBlockPos pos = entity.blockPosition().mutable();
int power = 0;
int dist = 64;
for (int i = 0; i < 64; i++) {
BlockState state = entity.level.getBlockState(pos);
if (state.is(EdenBlocks.GRAVITY_COMPRESSOR)) {
power = state.getValue(BlockStateProperties.POWER);
dist = i;
break;
}
pos.setY(pos.getY() - 1);
}
if (dist == 64) {
return 1.0;
}
float delta = Mth.clamp((dist + (float) (entity.getY() - (int) entity.getY())) / 64F, 0, 1);
delta = (1 - delta) * (power / 15F);
return power > 0 ? Mth.lerp(delta, 1.0, -1.0) : Mth.lerp(delta, 1.0, 0.1);
}
use of net.minecraft.core.BlockPos.MutableBlockPos in project Applied-Energistics-2 by AppliedEnergistics.
the class GrowingCrystalEntity method getAcceleratorCount.
private int getAcceleratorCount(BlockPos pos) {
int count = 0;
MutableBlockPos testPos = new MutableBlockPos();
for (Direction direction : Direction.values()) {
if (this.isPoweredAccelerator(testPos.setWithOffset(pos, direction))) {
count++;
}
}
return count;
}
Aggregations