Fixed AABB usage

This commit is contained in:
Frank 2023-12-19 15:22:26 +01:00
parent 5a2513d0a9
commit 95a1a21f04
3 changed files with 19 additions and 9 deletions

View file

@ -72,7 +72,11 @@ public class BlockEntityHydrothermalVent extends BlockEntity {
boolean active = state.getValue(HydrothermalVentBlock.ACTIVATED); boolean active = state.getValue(HydrothermalVentBlock.ACTIVATED);
POS.set(worldPosition).move(Direction.UP); POS.set(worldPosition).move(Direction.UP);
int height = active ? 85 : 25; int height = active ? 85 : 25;
AABB box = new AABB(POS.offset(-1, 0, -1), POS.offset(1, height, 1)); AABB box = new AABB(
new Vec3(POS.getX() - 1, POS.getY(), POS.getZ() - 1),
new Vec3(POS.getX() + 1, POS.getY() + height, POS.getZ() + 1)
);
List<LivingEntity> entities = level.getEntitiesOfClass(LivingEntity.class, box); List<LivingEntity> entities = level.getEntitiesOfClass(LivingEntity.class, box);
if (entities.size() > 0) { if (entities.size() > 0) {
while (POS.getY() < box.maxY) { while (POS.getY() < box.maxY) {

View file

@ -12,6 +12,7 @@ import net.minecraft.world.level.block.state.pattern.BlockPattern;
import net.minecraft.world.level.dimension.end.DragonRespawnAnimation; import net.minecraft.world.level.dimension.end.DragonRespawnAnimation;
import net.minecraft.world.level.dimension.end.EndDragonFight; import net.minecraft.world.level.dimension.end.EndDragonFight;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -72,7 +73,10 @@ public class EndDragonFightMixin {
BlockPos central = BlockPos.ZERO.relative(dir, 4); BlockPos central = BlockPos.ZERO.relative(dir, 4);
List<EndCrystal> crystalList = level.getEntitiesOfClass( List<EndCrystal> crystalList = level.getEntitiesOfClass(
EndCrystal.class, EndCrystal.class,
new AABB(central.below(255).south().west(), central.above(255).north().east()) new AABB(
new Vec3(central.getX() - 1, central.getY() - 255, central.getZ() + 1),
new Vec3(central.getX() - 1, central.getY() + 255, central.getZ() + 1)
)
); );
int count = crystalList.size(); int count = crystalList.size();

View file

@ -17,10 +17,12 @@ import net.minecraft.tags.BlockTags;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource; import net.minecraft.util.RandomSource;
import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import org.joml.Vector3f; import org.joml.Vector3f;
@ -76,8 +78,8 @@ public class HelixTreeFeature extends DefaultFeature {
world, world,
pos, pos,
new AABB( new AABB(
pos.offset((int) -dx, (int) dy1, (int) -dx), new Vec3(pos.getX() - dx, pos.getY() + dy1, pos.getZ() - dx),
pos.offset((int) dx, (int) dy2, (int) dx) new Vec3(pos.getX() + dx, pos.getY() + dy2, pos.getZ() + dx)
) )
); );
SplineHelper.scale(spline, scale); SplineHelper.scale(spline, scale);
@ -86,7 +88,7 @@ public class HelixTreeFeature extends DefaultFeature {
world, world,
EndBlocks.HELIX_TREE.getBark().defaultBlockState(), EndBlocks.HELIX_TREE.getBark().defaultBlockState(),
pos, pos,
(state) -> state.canBeReplaced() BlockBehaviour.BlockStateBase::canBeReplaced
); );
SplineHelper.rotateSpline(spline, (float) Math.PI); SplineHelper.rotateSpline(spline, (float) Math.PI);
SplineHelper.fillSplineForce( SplineHelper.fillSplineForce(
@ -94,7 +96,7 @@ public class HelixTreeFeature extends DefaultFeature {
world, world,
EndBlocks.HELIX_TREE.getBark().defaultBlockState(), EndBlocks.HELIX_TREE.getBark().defaultBlockState(),
pos, pos,
(state) -> state.canBeReplaced() BlockBehaviour.BlockStateBase::canBeReplaced
); );
SplineHelper.scale(spline2, scale); SplineHelper.scale(spline2, scale);
BlockPos leafStart = pos.offset( BlockPos leafStart = pos.offset(
@ -107,7 +109,7 @@ public class HelixTreeFeature extends DefaultFeature {
world, world,
EndBlocks.HELIX_TREE.getLog().defaultBlockState(), EndBlocks.HELIX_TREE.getLog().defaultBlockState(),
leafStart, leafStart,
(state) -> state.canBeReplaced() BlockBehaviour.BlockStateBase::canBeReplaced
); );
spline.clear(); spline.clear();