Prefix all unique fields with viaFabricPlus$

This commit is contained in:
FlorianMichael 2023-12-11 21:45:11 +01:00
parent a861237423
commit 736ac43868
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
8 changed files with 47 additions and 56 deletions

View File

@ -64,7 +64,7 @@ public abstract class MixinCamera {
cameraY = 1.62F;
} else if (cameraY < 1.62F) {
float delta = 1.62F - cameraY;
delta *= 0.4;
delta *= 0.4F;
cameraY = 1.62F - delta;
}
} else {

View File

@ -44,7 +44,7 @@ public abstract class MixinAbstractBlock_AbstractBlockState {
/**
* @author RK_01
* @reason Change block break speed for protocol hack
* @reason Change break speed for shulker blocks in < 1.14
*/
@Overwrite
public boolean isToolRequired() {
@ -58,23 +58,25 @@ public abstract class MixinAbstractBlock_AbstractBlockState {
@Inject(method = "getHardness", at = @At("RETURN"), cancellable = true)
private void changeHardness(BlockView world, BlockPos pos, CallbackInfoReturnable<Float> cir) {
final Block block = this.getBlock();
final var targetVersion = ProtocolHack.getTargetVersion();
final var block = this.getBlock();
if (block.equals(Blocks.END_STONE_BRICKS) || block.equals(Blocks.END_STONE_BRICK_SLAB) || block.equals(Blocks.END_STONE_BRICK_STAIRS) || block.equals(Blocks.END_STONE_BRICK_WALL)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
if (targetVersion.isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
cir.setReturnValue(0.8F);
}
} else if (block.equals(Blocks.PISTON) || block.equals(Blocks.STICKY_PISTON) || block.equals(Blocks.PISTON_HEAD)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
if (targetVersion.isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
cir.setReturnValue(0.5F);
}
} else if (block instanceof InfestedBlock) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
if (targetVersion.isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
cir.setReturnValue(0.75F);
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
} else if (targetVersion.isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
cir.setReturnValue(0F);
}
} else if (block.equals(Blocks.OBSIDIAN)) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
if (targetVersion.isOlderThanOrEqualTo(VersionEnum.b1_8tob1_8_1)) {
cir.setReturnValue(10.0F);
}
}

View File

@ -71,13 +71,13 @@ public abstract class MixinBoatEntity extends VehicleEntity {
public abstract LivingEntity getControllingPassenger();
@Unique
private double speedMultiplier = 0.07D;
private double viaFabricPlus$speedMultiplier = 0.07D;
@Unique
private int boatInterpolationSteps;
private int viaFabricPlus$boatInterpolationSteps;
@Unique
private Vec3d boatVelocity = Vec3d.ZERO;
private Vec3d viaFabricPlus$boatVelocity = Vec3d.ZERO;
public MixinBoatEntity(EntityType<?> type, World world) {
super(type, world);
@ -99,19 +99,19 @@ public abstract class MixinBoatEntity extends VehicleEntity {
this.prevX = x;
this.prevY = y;
this.prevZ = z;
this.boatInterpolationSteps = 0;
this.viaFabricPlus$boatInterpolationSteps = 0;
this.setPosition(x, y, z);
this.setRotation(yaw, pitch);
this.setVelocity(Vec3d.ZERO);
this.boatVelocity = Vec3d.ZERO;
this.viaFabricPlus$boatVelocity = Vec3d.ZERO;
} else {
if (!this.hasPassengers()) {
this.boatInterpolationSteps = interpolationSteps + 5;
this.viaFabricPlus$boatInterpolationSteps = interpolationSteps + 5;
} else {
if (this.squaredDistanceTo(x, y, z) <= 1) {
return;
}
this.boatInterpolationSteps = 3;
this.viaFabricPlus$boatInterpolationSteps = 3;
}
this.x = x;
@ -119,7 +119,7 @@ public abstract class MixinBoatEntity extends VehicleEntity {
this.z = z;
this.boatYaw = yaw;
this.boatPitch = pitch;
this.setVelocity(this.boatVelocity);
this.setVelocity(this.viaFabricPlus$boatVelocity);
}
}
}
@ -129,7 +129,7 @@ public abstract class MixinBoatEntity extends VehicleEntity {
super.setVelocityClient(x, y, z);
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
this.boatVelocity = new Vec3d(x, y, z);
this.viaFabricPlus$boatVelocity = new Vec3d(x, y, z);
}
}
@ -180,13 +180,13 @@ public abstract class MixinBoatEntity extends VehicleEntity {
}
if (this.getWorld().isClient && !this.hasPassengers()) {
if (this.boatInterpolationSteps > 0) {
final double newX = this.getX() + (this.x - this.getX()) / this.boatInterpolationSteps;
final double newY = this.getY() + (this.y - this.getY()) / this.boatInterpolationSteps;
final double newZ = this.getZ() + (this.z - this.getZ()) / this.boatInterpolationSteps;
final double newYaw = this.getYaw() + MathHelper.wrapDegrees(this.boatYaw - this.getYaw()) / this.boatInterpolationSteps;
final double newPitch = this.getPitch() + (this.boatPitch - this.getPitch()) / this.boatInterpolationSteps;
this.boatInterpolationSteps--;
if (this.viaFabricPlus$boatInterpolationSteps > 0) {
final double newX = this.getX() + (this.x - this.getX()) / this.viaFabricPlus$boatInterpolationSteps;
final double newY = this.getY() + (this.y - this.getY()) / this.viaFabricPlus$boatInterpolationSteps;
final double newZ = this.getZ() + (this.z - this.getZ()) / this.viaFabricPlus$boatInterpolationSteps;
final double newYaw = this.getYaw() + MathHelper.wrapDegrees(this.boatYaw - this.getYaw()) / this.viaFabricPlus$boatInterpolationSteps;
final double newPitch = this.getPitch() + (this.boatPitch - this.getPitch()) / this.viaFabricPlus$boatInterpolationSteps;
this.viaFabricPlus$boatInterpolationSteps--;
this.setPosition(newX, newY, newZ);
this.setRotation((float) newYaw, (float) newPitch);
} else {
@ -210,19 +210,19 @@ public abstract class MixinBoatEntity extends VehicleEntity {
if (this.getControllingPassenger() != null) {
final LivingEntity passenger = this.getControllingPassenger();
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_5_2)) {
final double xAcceleration = passenger.getVelocity().x * this.speedMultiplier;
final double zAcceleration = passenger.getVelocity().z * this.speedMultiplier;
final double xAcceleration = passenger.getVelocity().x * this.viaFabricPlus$speedMultiplier;
final double zAcceleration = passenger.getVelocity().z * this.viaFabricPlus$speedMultiplier;
this.setVelocity(this.getVelocity().add(xAcceleration, 0, zAcceleration));
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) {
if (passenger.forwardSpeed > 0) {
final double xAcceleration = -Math.sin(passenger.getYaw() * Math.PI / 180) * this.speedMultiplier * 0.05D;
final double zAcceleration = Math.cos(passenger.getYaw() * Math.PI / 180) * this.speedMultiplier * 0.05D;
final double xAcceleration = -Math.sin(passenger.getYaw() * Math.PI / 180) * this.viaFabricPlus$speedMultiplier * 0.05D;
final double zAcceleration = Math.cos(passenger.getYaw() * Math.PI / 180) * this.viaFabricPlus$speedMultiplier * 0.05D;
this.setVelocity(this.getVelocity().add(xAcceleration, 0, zAcceleration));
}
} else {
final float boatAngle = passenger.getYaw() - passenger.sidewaysSpeed * 90F;
final double xAcceleration = -Math.sin(boatAngle * Math.PI / 180) * this.speedMultiplier * passenger.forwardSpeed * 0.05D;
final double zAcceleration = Math.cos(boatAngle * Math.PI / 180) * this.speedMultiplier * passenger.forwardSpeed * 0.05D;
final double xAcceleration = -Math.sin(boatAngle * Math.PI / 180) * this.viaFabricPlus$speedMultiplier * passenger.forwardSpeed * 0.05D;
final double zAcceleration = Math.cos(boatAngle * Math.PI / 180) * this.viaFabricPlus$speedMultiplier * passenger.forwardSpeed * 0.05D;
this.setVelocity(this.getVelocity().add(xAcceleration, 0, zAcceleration));
}
}
@ -234,15 +234,15 @@ public abstract class MixinBoatEntity extends VehicleEntity {
newHorizontalSpeed = 0.35D;
}
if (newHorizontalSpeed > oldHorizontalSpeed && this.speedMultiplier < 0.35D) {
this.speedMultiplier += (0.35D - this.speedMultiplier) / 35;
if (this.speedMultiplier > 0.35D) {
this.speedMultiplier = 0.35D;
if (newHorizontalSpeed > oldHorizontalSpeed && this.viaFabricPlus$speedMultiplier < 0.35D) {
this.viaFabricPlus$speedMultiplier += (0.35D - this.viaFabricPlus$speedMultiplier) / 35;
if (this.viaFabricPlus$speedMultiplier > 0.35D) {
this.viaFabricPlus$speedMultiplier = 0.35D;
}
} else {
this.speedMultiplier -= (this.speedMultiplier - 0.07D) / 35;
if (this.speedMultiplier < 0.07D) {
this.speedMultiplier = 0.07D;
this.viaFabricPlus$speedMultiplier -= (this.viaFabricPlus$speedMultiplier - 0.07D) / 35;
if (this.viaFabricPlus$speedMultiplier < 0.07D) {
this.viaFabricPlus$speedMultiplier = 0.07D;
}
}

View File

@ -129,7 +129,6 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) {
return 9.0E-4D;
}
return MathHelper.square(n);
}
@ -190,7 +189,6 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_1)) {
return input.movementForward >= 0.8F;
}
return input.hasForwardMovement();
}
@ -210,7 +208,6 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
return false; // Disable all water related movement
}
return self.isTouchingWater();
}
@ -220,7 +217,6 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_8)) {
return ticksSinceLastPositionPacketSent - 1;
}
return ticksSinceLastPositionPacketSent;
}

View File

@ -118,7 +118,6 @@ public abstract class MixinLivingEntity extends Entity {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_15_2)) {
return Double.MAX_VALUE;
}
return instance.getFluidHeight(tagKey);
}
@ -136,7 +135,6 @@ public abstract class MixinLivingEntity extends Entity {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
return false;
}
return jumping;
}
@ -147,7 +145,6 @@ public abstract class MixinLivingEntity extends Entity {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
return false;
}
return instance.horizontalCollision;
}
@ -156,7 +153,6 @@ public abstract class MixinLivingEntity extends Entity {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
return true;
}
return movingDown;
}
@ -165,7 +161,6 @@ public abstract class MixinLivingEntity extends Entity {
if (!this.hasStatusEffect(StatusEffects.SLOW_FALLING) && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_12_2)) {
return;
}
instance.onLanding();
}

View File

@ -38,15 +38,16 @@ public abstract class MixinPlayerEntityRenderer {
@Inject(method = "getPositionOffset(Lnet/minecraft/client/network/AbstractClientPlayerEntity;F)Lnet/minecraft/util/math/Vec3d;", at = @At("RETURN"), cancellable = true)
private void modifySleepingOffset(AbstractClientPlayerEntity player, float delta, CallbackInfoReturnable<Vec3d> cir) {
if (player.getPose() == EntityPose.SLEEPING) {
final Direction sleepingDir = player.getSleepingDirection();
final var targetVersion = ProtocolHack.getTargetVersion();
final var sleepingDir = player.getSleepingDirection();
if (sleepingDir != null) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
if (targetVersion.isOlderThanOrEqualTo(VersionEnum.r1_13_2)) {
cir.setReturnValue(cir.getReturnValue().subtract(sleepingDir.getOffsetX() * 0.4, 0, sleepingDir.getOffsetZ() * 0.4));
}
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.b1_5tob1_5_2)) {
if (targetVersion.isOlderThanOrEqualTo(VersionEnum.b1_5tob1_5_2)) {
cir.setReturnValue(cir.getReturnValue().subtract(sleepingDir.getOffsetX() * 0.1, 0, sleepingDir.getOffsetZ() * 0.1));
}
if (ProtocolHack.getTargetVersion().isBetweenInclusive(VersionEnum.b1_6tob1_6_6, VersionEnum.r1_7_6tor1_7_10)) {
if (targetVersion.isBetweenInclusive(VersionEnum.b1_6tob1_6_6, VersionEnum.r1_7_6tor1_7_10)) {
cir.setReturnValue(cir.getReturnValue().subtract(0, 0.3F, 0));
}
}

View File

@ -63,7 +63,7 @@ public abstract class MixinWolfEntity extends TameableEntity implements Angerabl
final Item item = itemStack.getItem();
if (this.isTamed()) {
if (item.isFood()) {
if (item.getFoodComponent().isMeat() && this.getWolfHealth() < 20.0F) {
if (item.getFoodComponent().isMeat() && this.viaFabricPlus$getWolfHealth() < 20.0F) {
if (!player.getAbilities().creativeMode) itemStack.decrement(1);
this.heal((float) item.getFoodComponent().getHunger());
cir.setReturnValue(ActionResult.SUCCESS);
@ -91,14 +91,13 @@ public abstract class MixinWolfEntity extends TameableEntity implements Angerabl
@Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/WolfEntity;getHealth()F"))
private float fixWolfHealth(WolfEntity instance) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_14_4)) {
return this.getWolfHealth();
return this.viaFabricPlus$getWolfHealth();
}
return instance.getHealth();
}
@Unique
private float getWolfHealth() {
private float viaFabricPlus$getWolfHealth() {
return WolfHealthTracker.get(ProtocolHack.getPlayNetworkUserConnection()).getWolfHealth(this.getId(), this.getHealth());
}

View File

@ -58,7 +58,6 @@ public abstract class MixinAxeItem extends MiningToolItem {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
return false;
}
return super.isSuitableFor(state);
}
@ -76,7 +75,6 @@ public abstract class MixinAxeItem extends MiningToolItem {
} else if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_16_4tor1_16_5)) {
return viaFabricPlus$effective_materials_r1_16_5.contains(Material1_19_4.getMaterial(state)) ? this.miningSpeed : viaFabricPlus$effective_blocks_r1_16_5.contains(state.getBlock()) ? this.miningSpeed : 1.0F;
}
return super.getMiningSpeedMultiplier(stack, state);
}