- 204
- 7
- 25
Всем добрый вечер!
Появилась необходимость в использовании некоторых методов из Forge 1.16.5 на Forge 1.7.10, а именно:
другие методы необходимые для Entity#collide
в 1.7.10 нет VoxelShapes, ReuseableStream, ISelectionContext
Как или чем можно заменить метод collide? Может ктото уже занимался этим и есть готовое решение?
Спасибо
Появилась необходимость в использовании некоторых методов из Forge 1.16.5 на Forge 1.7.10, а именно:
Entity#collide:
public Vector3d collide(Vector3d p_213306_1_) {
AxisAlignedBB axisalignedbb = this.getBoundingBox();
ISelectionContext iselectioncontext = ISelectionContext.of(this);
VoxelShape voxelshape = this.level.getWorldBorder().getCollisionShape();
Stream<VoxelShape> stream = VoxelShapes.joinIsNotEmpty(voxelshape, VoxelShapes.create(axisalignedbb.deflate(1.0E-7)), IBooleanFunction.AND) ? Stream.empty() : Stream.of(voxelshape);
Stream<VoxelShape> stream1 = this.level.getEntityCollisions(this, axisalignedbb.expandTowards(p_213306_1_), (p_233561_0_) -> {
return true;
});
ReuseableStream<VoxelShape> reuseablestream = new ReuseableStream(Stream.concat(stream1, stream));
Vector3d vector3d = p_213306_1_.lengthSqr() == 0.0 ? p_213306_1_ : collideBoundingBoxHeuristically(this, p_213306_1_, axisalignedbb, this.level, iselectioncontext, reuseablestream);
boolean flag = p_213306_1_.x != vector3d.x;
boolean flag1 = p_213306_1_.y != vector3d.y;
boolean flag2 = p_213306_1_.z != vector3d.z;
boolean flag3 = this.onGround || flag1 && p_213306_1_.y < 0.0;
if (this.maxUpStep > 0.0F && flag3 && (flag || flag2)) {
Vector3d vector3d1 = collideBoundingBoxHeuristically(this, new Vector3d(p_213306_1_.x, (double)this.maxUpStep, p_213306_1_.z), axisalignedbb, this.level, iselectioncontext, reuseablestream);
Vector3d vector3d2 = collideBoundingBoxHeuristically(this, new Vector3d(0.0, (double)this.maxUpStep, 0.0), axisalignedbb.expandTowards(p_213306_1_.x, 0.0, p_213306_1_.z), this.level, iselectioncontext, reuseablestream);
if (vector3d2.y < (double)this.maxUpStep) {
Vector3d vector3d3 = collideBoundingBoxHeuristically(this, new Vector3d(p_213306_1_.x, 0.0, p_213306_1_.z), axisalignedbb.move(vector3d2), this.level, iselectioncontext, reuseablestream).add(vector3d2);
if (getHorizontalDistanceSqr(vector3d3) > getHorizontalDistanceSqr(vector3d1)) {
vector3d1 = vector3d3;
}
}
if (getHorizontalDistanceSqr(vector3d1) > getHorizontalDistanceSqr(vector3d)) {
return vector3d1.add(collideBoundingBoxHeuristically(this, new Vector3d(0.0, -vector3d1.y + p_213306_1_.y, 0.0), axisalignedbb.move(vector3d1), this.level, iselectioncontext, reuseablestream));
}
}
return vector3d;
}
Entity.class:
public static Vector3d collideBoundingBoxHeuristically(@Nullable Entity p_223307_0_, Vector3d p_223307_1_, AxisAlignedBB p_223307_2_, World p_223307_3_, ISelectionContext p_223307_4_, ReuseableStream<VoxelShape> p_223307_5_) {
boolean flag = p_223307_1_.x == 0.0;
boolean flag1 = p_223307_1_.y == 0.0;
boolean flag2 = p_223307_1_.z == 0.0;
if (flag && flag1 || flag && flag2 || flag1 && flag2) {
return collideBoundingBox(p_223307_1_, p_223307_2_, p_223307_3_, p_223307_4_, p_223307_5_);
} else {
ReuseableStream<VoxelShape> reuseablestream = new ReuseableStream(Stream.concat(p_223307_5_.getStream(), p_223307_3_.getBlockCollisions(p_223307_0_, p_223307_2_.expandTowards(p_223307_1_))));
return collideBoundingBoxLegacy(p_223307_1_, p_223307_2_, reuseablestream);
}
}
public static Vector3d collideBoundingBoxLegacy(Vector3d p_223310_0_, AxisAlignedBB p_223310_1_, ReuseableStream<VoxelShape> p_223310_2_) {
double d0 = p_223310_0_.x;
double d1 = p_223310_0_.y;
double d2 = p_223310_0_.z;
if (d1 != 0.0) {
d1 = VoxelShapes.collide(Axis.Y, p_223310_1_, p_223310_2_.getStream(), d1);
if (d1 != 0.0) {
p_223310_1_ = p_223310_1_.move(0.0, d1, 0.0);
}
}
boolean flag = Math.abs(d0) < Math.abs(d2);
if (flag && d2 != 0.0) {
d2 = VoxelShapes.collide(Axis.Z, p_223310_1_, p_223310_2_.getStream(), d2);
if (d2 != 0.0) {
p_223310_1_ = p_223310_1_.move(0.0, 0.0, d2);
}
}
if (d0 != 0.0) {
d0 = VoxelShapes.collide(Axis.X, p_223310_1_, p_223310_2_.getStream(), d0);
if (!flag && d0 != 0.0) {
p_223310_1_ = p_223310_1_.move(d0, 0.0, 0.0);
}
}
if (!flag && d2 != 0.0) {
d2 = VoxelShapes.collide(Axis.Z, p_223310_1_, p_223310_2_.getStream(), d2);
}
return new Vector3d(d0, d1, d2);
}
public static Vector3d collideBoundingBox(Vector3d p_213313_0_, AxisAlignedBB p_213313_1_, IWorldReader p_213313_2_, ISelectionContext p_213313_3_, ReuseableStream<VoxelShape> p_213313_4_) {
double d0 = p_213313_0_.x;
double d1 = p_213313_0_.y;
double d2 = p_213313_0_.z;
if (d1 != 0.0) {
d1 = VoxelShapes.collide(Axis.Y, p_213313_1_, p_213313_2_, d1, p_213313_3_, p_213313_4_.getStream());
if (d1 != 0.0) {
p_213313_1_ = p_213313_1_.move(0.0, d1, 0.0);
}
}
boolean flag = Math.abs(d0) < Math.abs(d2);
if (flag && d2 != 0.0) {
d2 = VoxelShapes.collide(Axis.Z, p_213313_1_, p_213313_2_, d2, p_213313_3_, p_213313_4_.getStream());
if (d2 != 0.0) {
p_213313_1_ = p_213313_1_.move(0.0, 0.0, d2);
}
}
if (d0 != 0.0) {
d0 = VoxelShapes.collide(Axis.X, p_213313_1_, p_213313_2_, d0, p_213313_3_, p_213313_4_.getStream());
if (!flag && d0 != 0.0) {
p_213313_1_ = p_213313_1_.move(d0, 0.0, 0.0);
}
}
if (!flag && d2 != 0.0) {
d2 = VoxelShapes.collide(Axis.Z, p_213313_1_, p_213313_2_, d2, p_213313_3_, p_213313_4_.getStream());
}
return new Vector3d(d0, d1, d2);
}
в 1.7.10 нет VoxelShapes, ReuseableStream, ISelectionContext
Как или чем можно заменить метод collide? Может ктото уже занимался этим и есть готовое решение?
Спасибо