Skip to content

Commit

Permalink
small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Nov 12, 2023
1 parent 18b4340 commit 9878f24
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,16 @@ private static double injectMovementInputToVelocity(double epsilon) {
}

@Inject(method = "getVelocityAffectingPos", at = @At("HEAD"), cancellable = true)
public void injectGetVelocityAffectingPos(CallbackInfoReturnable<BlockPos> cir) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
cir.setReturnValue(BlockPos.ofFloored(pos.x, getBoundingBox().minY - 0.5000001, pos.z));
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
cir.setReturnValue(BlockPos.ofFloored(pos.x, getBoundingBox().minY - 1, pos.z));
}
public void replaceAffectingVelocityMagnitude(CallbackInfoReturnable<BlockPos> cir) {
final VersionEnum target = ProtocolHack.getTargetVersion();

if (target.isOlderThanOrEqualTo(VersionEnum.r1_19_4)) {
cir.setReturnValue(BlockPos.ofFloored(pos.x, getBoundingBox().minY - (target.isOlderThanOrEqualTo(VersionEnum.r1_14_4) ? 1 : 0.5000001), pos.z));
}
}

@Inject(method = "getRotationVector(FF)Lnet/minecraft/util/math/Vec3d;", at = @At("HEAD"), cancellable = true)
public void onGetRotationVector(float pitch, float yaw, CallbackInfoReturnable<Vec3d> cir) {
public void revertCalculation(float pitch, float yaw, CallbackInfoReturnable<Vec3d> cir) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
cir.setReturnValue(Vec3d.fromPolar(pitch, yaw));
}
Expand Down Expand Up @@ -112,8 +111,9 @@ private void modifyFluidMovementBoundingBox(TagKey<Fluid> fluidTag, double d, Ca
int minZ = MathHelper.floor(box.minZ);
int maxZ = MathHelper.ceil(box.maxZ);

if (!world.isRegionLoaded(minX, minY, minZ, maxX, maxY, maxZ))
if (!world.isRegionLoaded(minX, minY, minZ, maxX, maxY, maxZ)) {
ci.setReturnValue(false);
}

double waterHeight = 0;
boolean foundFluid = false;
Expand Down Expand Up @@ -168,7 +168,6 @@ public double changeBlockCollisionConstant(double constant) {
return constant;
}

// Not relevant for GamePlay
@Redirect(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;onLanding()V"))
public void revertOnLanding(Entity instance) {
if (ProtocolHack.getTargetVersion().isNewerThanOrEqualTo(VersionEnum.r1_19)) {
Expand Down

0 comments on commit 9878f24

Please sign in to comment.