mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-12-22 14:59:22 +01:00
improved plant boost and particle height calculations
This commit is contained in:
parent
2953dd0eea
commit
fe71e62ad4
3 changed files with 17 additions and 4 deletions
|
@ -321,4 +321,16 @@ public final class Helper {
|
|||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static BlockPos getClosestAirAboveGround(Level level, BlockPos pos, int radius) {
|
||||
for (var i = 0; i < radius; i++) {
|
||||
var up = pos.above(i);
|
||||
if (level.isEmptyBlock(up) && !level.isEmptyBlock(up.below()))
|
||||
return up;
|
||||
var dn = pos.below(i);
|
||||
if (level.isEmptyBlock(dn) && !level.isEmptyBlock(dn.below()))
|
||||
return dn;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.naturesaura.chunk.effect;
|
||||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.ModConfig;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
|
@ -65,9 +66,9 @@ public class PlantBoostEffect implements IDrainSpotEffect {
|
|||
return;
|
||||
for (var i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) {
|
||||
var x = Mth.floor(pos.getX() + (2 * level.random.nextFloat() - 1) * this.dist);
|
||||
var y = Mth.floor(pos.getY() + (2 * level.random.nextFloat() - 1) * this.dist);
|
||||
var y = Mth.floor(pos.getY() + (2 * level.random.nextFloat() - 1) * this.dist / 2);
|
||||
var z = Mth.floor(pos.getZ() + (2 * level.random.nextFloat() - 1) * this.dist);
|
||||
var plantPos = new BlockPos(x, y, z).below();
|
||||
var plantPos = Helper.getClosestAirAboveGround(level, new BlockPos(x, y, z), this.dist / 2).below();
|
||||
if (plantPos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(plantPos)) {
|
||||
if (NaturesAuraAPI.instance().isEffectPowderActive(level, plantPos, PlantBoostEffect.NAME))
|
||||
continue;
|
||||
|
|
|
@ -34,7 +34,6 @@ import net.minecraft.world.level.block.Blocks;
|
|||
import net.minecraft.world.level.block.BonemealableBlock;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.block.MyceliumBlock;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
@ -110,8 +109,9 @@ public class ClientEvents {
|
|||
var amount = Mth.floor(190 * ModConfig.instance.excessParticleAmount.get());
|
||||
for (var i = 0; i < amount; i++) {
|
||||
var x = Mth.floor(mc.player.getX()) + mc.level.random.nextInt(64) - 32;
|
||||
var y = Mth.floor(mc.player.getY()) + mc.level.random.nextInt(32) - 16;
|
||||
var z = Mth.floor(mc.player.getZ()) + mc.level.random.nextInt(64) - 32;
|
||||
var pos = new BlockPos(x, mc.level.getHeight(Heightmap.Types.WORLD_SURFACE, x, z) - 1, z);
|
||||
var pos = Helper.getClosestAirAboveGround(mc.level, new BlockPos(x, y, z), 16).below();
|
||||
var state = mc.level.getBlockState(pos);
|
||||
var block = state.getBlock();
|
||||
if (block instanceof BonemealableBlock || block instanceof IPlantable || block instanceof LeavesBlock || block instanceof MyceliumBlock) {
|
||||
|
|
Loading…
Reference in a new issue