use of com.bergerkiller.generated.net.minecraft.world.phys.AxisAlignedBBHandle in project BKCommonLib by bergerhealer.
the class EntityMoveHandler_1_14 method world_getEntityCollisionShapes.
private Stream<VoxelShapeHandle> world_getEntityCollisionShapes(EntityHandle entity, double mx, double my, double mz) {
if (!this.entityCollisionEnabled) {
return Stream.empty();
}
AxisAlignedBBHandle entityBounds = entity.getBoundingBox();
final double MIN_MOVE = 1.0E-7D;
VoxelShapeHandle voxelshapeAABBMoved = VoxelShapeHandle.fromAABB(entityBounds.translate(mx > 0.0D ? -MIN_MOVE : MIN_MOVE, my > 0.0D ? -MIN_MOVE : MIN_MOVE, mz > 0.0D ? -MIN_MOVE : MIN_MOVE));
VoxelShapeHandle voxelshapeBounds = VoxelShapeHandle.mergeOnlyFirst(VoxelShapeHandle.fromAABB(entityBounds.transformB(mx, my, mz).growUniform(MIN_MOVE)), voxelshapeAABBMoved);
if (voxelshapeBounds.isEmpty()) {
return Stream.empty();
}
// default VoxelShape IWorldReader::a(@Nullable Entity entity, VoxelShape voxelshape, boolean flag, Set<Entity> set)
AxisAlignedBBHandle axisalignedbb = voxelshapeBounds.getBoundingBox();
VoxelShapeHandle shape = VoxelShapeHandle.empty();
if (entity != null && this.entityCollisionEnabled) {
List<EntityHandle> list = entity.getWorld().getNearbyEntities(entity, axisalignedbb.growUniform(0.25D));
for (EntityHandle entity1 : list) {
if (!entity.isInSameVehicle(entity1)) {
// BKCommonLib start: block collision event handler
AxisAlignedBBHandle axisalignedbb1 = entity1.getOtherBoundingBox();
if (axisalignedbb1 != null && axisalignedbb1.bbTransformA(axisalignedbb) && controller.onEntityCollision(entity1.getBukkitEntity())) {
shape = VoxelShapeHandle.merge(shape, VoxelShapeHandle.fromAABB(axisalignedbb1));
}
axisalignedbb1 = entity.getEntityBoundingBox(entity1);
if (axisalignedbb1 != null && axisalignedbb1.bbTransformA(axisalignedbb) && controller.onEntityCollision(entity1.getBukkitEntity())) {
shape = VoxelShapeHandle.merge(shape, VoxelShapeHandle.fromAABB(axisalignedbb1));
}
// BKCommonLib end
/*
if (axisalignedbb1 != null && axisalignedbb1.c(axisalignedbb)) {
voxelshape1 = VoxelShapes.b(voxelshape1, VoxelShapes.a(axisalignedbb1), OperatorBoolean.OR);
if (flag) {
break;
}
}
axisalignedbb1 = entity.j(entity1);
if (axisalignedbb1 != null && axisalignedbb1.c(axisalignedbb)) {
voxelshape1 = VoxelShapes.b(voxelshape1, VoxelShapes.a(axisalignedbb1), OperatorBoolean.OR);
if (flag) {
break;
}
}
*/
}
}
}
if (shape.isEmpty()) {
return Stream.empty();
} else {
return MountiplexUtil.toStream(shape);
}
}
use of com.bergerkiller.generated.net.minecraft.world.phys.AxisAlignedBBHandle in project BKCommonLib by bergerhealer.
the class EntityMoveHandler_1_14 method world_getBlockCollisionShapes.
private Stream<VoxelShapeHandle> world_getBlockCollisionShapes(EntityHandle entity, double mx, double my, double mz) {
if (!this.blockCollisionEnabled) {
return Stream.empty();
}
AxisAlignedBBHandle entityBounds = this.getBlockBoundingBox(entity);
final double MIN_MOVE = 1.0E-7D;
VoxelShapeHandle voxelshapeAABB = VoxelShapeHandle.fromAABB(entityBounds);
VoxelShapeHandle voxelshapeAABBMoved = VoxelShapeHandle.fromAABB(entityBounds.translate(mx > 0.0D ? -MIN_MOVE : MIN_MOVE, my > 0.0D ? -MIN_MOVE : MIN_MOVE, mz > 0.0D ? -MIN_MOVE : MIN_MOVE));
VoxelShapeHandle voxelshapeBounds = VoxelShapeHandle.mergeOnlyFirst(VoxelShapeHandle.fromAABB(entityBounds.transformB(mx, my, mz).growUniform(MIN_MOVE)), voxelshapeAABBMoved);
if (voxelshapeBounds.isEmpty()) {
return Stream.empty();
}
// Check and update that the entity is within the world border
WorldHandle world = entity.getWorld();
// Execute generated method and convert to Stream<VoxelShapeHandle>
return logic.getBlockCollisions(world, this, voxelshapeBounds, voxelshapeAABB);
}
use of com.bergerkiller.generated.net.minecraft.world.phys.AxisAlignedBBHandle in project BKCommonLib by bergerhealer.
the class MapPlayerInput method updateInterception.
private void updateInterception(boolean intercept) {
// No receivers, do not do input interception
if (!intercept) {
updateInputInterception(false);
return;
}
// If the player is already inside a vehicle, we can not fake-mount him
if (player.isInsideVehicle()) {
updateInputInterception(false);
return;
}
// Since Minecraft 1.16, it is not possible to be on the mount while sneaking
if (!CommonCapabilities.VEHICLE_EXIT_CANCELLABLE && player.isSneaking()) {
updateInputInterception(false);
return;
}
// Verify the player isn't flying, it results in a kick
if (!player.isFlying() && !player.isOnGround()) {
// Check if there is a block below the player, which means onGround is actually true
// This is because, when the player is 'floating' while intercepting, onGround stays false
EntityHandle playerHandle = EntityHandle.fromBukkit(player);
double half_width = 0.5 * (double) playerHandle.getWidth();
double below = 0.1;
AxisAlignedBBHandle below_bounds = AxisAlignedBBHandle.createNew(playerHandle.getLocX() - half_width, playerHandle.getLocY() - below, playerHandle.getLocZ() - half_width, playerHandle.getLocX() + half_width, playerHandle.getLocY(), playerHandle.getLocZ() + half_width);
if (WorldHandle.fromBukkit(player.getWorld()).isNotCollidingWithBlocks(playerHandle, below_bounds)) {
updateInputInterception(false);
return;
}
}
// Allowed
this.updateInputInterception(true);
}
use of com.bergerkiller.generated.net.minecraft.world.phys.AxisAlignedBBHandle in project BKCommonLib by bergerhealer.
the class EntityMoveHandler method getBlockBoundingBox.
// Gets the AxisAlignedBB bounding box to use for computing Block Collisions
protected AxisAlignedBBHandle getBlockBoundingBox(EntityHandle entity) {
AxisAlignedBBHandle boundingBox = entity.getBoundingBox();
if (this.blockCollisionEnabled && this.customBlockCollisionBounds != null) {
double x = 0.5 * (boundingBox.getMinX() + boundingBox.getMaxX());
double y = boundingBox.getMinY();
double z = 0.5 * (boundingBox.getMinZ() + boundingBox.getMaxZ());
return AxisAlignedBBHandle.createNew(x - 0.5 * this.customBlockCollisionBounds.getX(), y, z - 0.5 * this.customBlockCollisionBounds.getZ(), x + 0.5 * this.customBlockCollisionBounds.getX(), y + this.customBlockCollisionBounds.getY(), z + 0.5 * this.customBlockCollisionBounds.getZ());
}
return boundingBox;
}
use of com.bergerkiller.generated.net.minecraft.world.phys.AxisAlignedBBHandle in project BKCommonLib by bergerhealer.
the class EntityMoveHandler_1_13 method onBlockCollided.
// Called from getBlockCollisions_method
public boolean onBlockCollided(Block block) {
// Find out what direction the block is hit
BlockFace hitFace;
AxisAlignedBBHandle entityBounds = this.that.getBoundingBox();
if (entityBounds.getMaxY() > (block.getY() + 1.0)) {
hitFace = BlockFace.UP;
} else if (entityBounds.getMinY() < (double) block.getY()) {
hitFace = BlockFace.DOWN;
} else {
double dx = this.that.getLocX() - block.getX() - 0.5;
double dz = this.that.getLocZ() - block.getZ() - 0.5;
hitFace = FaceUtil.getDirection(dx, dz, false);
}
// Block collision event
return controller.onBlockCollision(block, hitFace);
}
Aggregations