Skip to content

Commit

Permalink
Updated Via API usage
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed Feb 14, 2024
1 parent 267d6da commit f151643
Show file tree
Hide file tree
Showing 115 changed files with 325 additions and 325 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static void init() {
}

// Rebuilds the item selection screen grid
if (newVersion.olderThanOrEquals(LegacyProtocolVersion.c0_28toc0_30)) {
if (newVersion.olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
GridItemSelectionScreen.INSTANCE.itemGrid = null;
}
}));
Expand All @@ -125,7 +125,7 @@ public static void init() {
* @return The maximum chat length
*/
public static int getChatLength() {
if (ProtocolHack.getTargetVersion().olderThanOrEquals(LegacyProtocolVersion.c0_28toc0_30)) {
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
final ClientPlayNetworkHandler handler = MinecraftClient.getInstance().getNetworkHandler();
final ExtensionProtocolMetadataStorage extensionProtocol = ((IClientConnection) handler.getConnection()).viaFabricPlus$getUserConnection().get(ExtensionProtocolMetadataStorage.class);

Expand All @@ -136,7 +136,7 @@ public static int getChatLength() {
}
} else if (ProtocolHack.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) {
return 512;
} else if (ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_9_3)) {
} else if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_9_3)) {
return 100;
} else {
return 256;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ EntityType.ARROW, linkedHashMap(
for (Map.Entry<ProtocolVersion, EntityDimensions> entry : dimensionMap.entrySet()) {
final ProtocolVersion version = entry.getKey();
final EntityDimensions dimensions = entry.getValue();
if (oldVersion.newerThan(version) && newVersion.olderThanOrEquals(version)) {
if (oldVersion.newerThan(version) && newVersion.olderThanOrEqualTo(version)) {
entityType.dimensions = dimensions;
break;
}
if (newVersion.newerThanOrEquals(version) && oldVersion.olderThanOrEquals(version)) {
if (newVersion.newerThanOrEqualTo(version) && oldVersion.olderThanOrEqualTo(version)) {
entityType.dimensions = dimensions;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -977,10 +977,10 @@ public class RenderableGlyphDiff {
public static boolean isGlyphRenderable(final int codePoint) {
final ProtocolVersion targetVersion = ProtocolHack.getTargetVersion();

if (targetVersion.newerThanOrEquals(v1_20)) { // 1.20 switched to using Unihex as a main font
return !RENDERABLE_GLYPH_DIFF.containsKey(codePoint) || targetVersion.newerThanOrEquals(RENDERABLE_GLYPH_DIFF.get(codePoint));
if (targetVersion.newerThanOrEqualTo(v1_20)) { // 1.20 switched to using Unihex as a main font
return !RENDERABLE_GLYPH_DIFF.containsKey(codePoint) || targetVersion.newerThanOrEqualTo(RENDERABLE_GLYPH_DIFF.get(codePoint));
} else {
return RENDERABLE_GLYPH_DIFF_LEGACY.containsKey(codePoint) && targetVersion.newerThanOrEquals(RENDERABLE_GLYPH_DIFF_LEGACY.get(codePoint));
return RENDERABLE_GLYPH_DIFF_LEGACY.containsKey(codePoint) && targetVersion.newerThanOrEqualTo(RENDERABLE_GLYPH_DIFF_LEGACY.get(codePoint));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public ItemStack craft(RecipeInputInventory inv, DynamicRegistryManager registry

BannerPattern_1_13_2 pattern = getBannerPattern(inv);
if (pattern != null) {
DyeColor color = ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_12_2) ? DyeColor.BLACK : DyeColor.WHITE;
DyeColor color = ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2) ? DyeColor.BLACK : DyeColor.WHITE;
for (int i = 0; i < inv.size(); i++) {
Item item = inv.getStack(i).getItem();
if (item instanceof DyeItem dyeItem) {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void trackPlayerAction(final PlayerActionC2SPacket.Action action, final B
final ClientPlayerEntity player = MinecraftClient.getInstance().player;

final Vec2f rotation;
if (ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_16_1)) {
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_1)) {
rotation = null;
} else {
rotation = new Vec2f(player.getYaw(), player.getPitch());
Expand All @@ -58,9 +58,9 @@ public void handleBlockBreakAck(final BlockPos blockPos, final BlockState expect
final var oldPlayerState = unAckedActions.remove(Pair.of(blockPos, action));
final var actualState = world.getBlockState(blockPos);

if ((oldPlayerState == null || !allGood || action != PlayerActionC2SPacket.Action.START_DESTROY_BLOCK && actualState != expectedState) && (actualState != expectedState || ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_15_2))) {
if ((oldPlayerState == null || !allGood || action != PlayerActionC2SPacket.Action.START_DESTROY_BLOCK && actualState != expectedState) && (actualState != expectedState || ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2))) {
world.setBlockState(blockPos, expectedState, Block.NOTIFY_ALL | Block.FORCE_STATE);
if (oldPlayerState != null && (ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_16_1) || (world == player.getWorld() && player.collidesWithStateAtPos(blockPos, expectedState)))) {
if (oldPlayerState != null && (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_1) || (world == player.getWorld() && player.collidesWithStateAtPos(blockPos, expectedState)))) {
final Vec3d oldPlayerPosition = oldPlayerState.getKey();
if (oldPlayerState.getValue() != null) {
player.updatePositionAndAngles(oldPlayerPosition.x, oldPlayerPosition.y, oldPlayerPosition.z, oldPlayerState.getValue().x, oldPlayerState.getValue().y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static PacketHandler handleJoinGame(final PacketHandler parentHandler) {
parentHandler.handle(wrapper);
if (wrapper.isCancelled()) return;

if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEquals(LegacyProtocolVersion.c0_28toc0_30)) {
if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
for (Tag dimension : wrapper.get(Type.NAMED_COMPOUND_TAG, 0).<CompoundTag>get("minecraft:dimension_type").<ListTag>get("value")) {
changeDimensionTagHeight(wrapper.user(), ((CompoundTag) dimension).get("element"));
}
Expand All @@ -61,7 +61,7 @@ public static PacketHandler handleRespawn(final PacketHandler parentHandler) {
parentHandler.handle(wrapper);
if (wrapper.isCancelled()) return;

if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEquals(LegacyProtocolVersion.c0_28toc0_30)) {
if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
changeDimensionTagHeight(wrapper.user(), wrapper.get(Type.NAMED_COMPOUND_TAG, 0));
}
};
Expand All @@ -72,7 +72,7 @@ public static PacketHandler handleChunkData(final PacketHandler parentHandler) {
parentHandler.handle(wrapper);
if (wrapper.isCancelled()) return;

if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEquals(LegacyProtocolVersion.c0_28toc0_30)) {
if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
wrapper.resetReader();
final Chunk chunk = wrapper.read(new ChunkType1_17(16));
wrapper.write(new ChunkType1_17(chunk.getSections().length), chunk);
Expand Down Expand Up @@ -162,7 +162,7 @@ public void register() {
};

return wrapper -> {
if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEquals(LegacyProtocolVersion.c0_28toc0_30)) {
if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) {
classicLightHandler.handle(wrapper);
} else {
parentHandler.handle(wrapper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static Vector3f getMountedHeightOffset(final Entity entity, final Entity
if (entity instanceof BoatEntity boatEntity) {
if (!boatEntity.hasPassenger(passenger)) return new Vector3f();

if (ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
yOffset = -0.3F;
final float xOffset = MathHelper.cos(boatEntity.getYaw() * MathHelper.PI / 180F);
final float zOffset = MathHelper.sin(boatEntity.getYaw() * MathHelper.PI / 180F);
Expand Down Expand Up @@ -149,7 +149,7 @@ public static Vector3f getMountedHeightOffset(final Entity entity, final Entity
*/
public static double getHeightOffset(final Entity entity) {
if (entity instanceof AllayEntity || entity instanceof VexEntity) {
if (ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_19_1)) {
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_1)) {
return 0D;
} else {
return 0.4D;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void reorderCompression(int compressionThreshold, boolean rejectBad, Cal

@Inject(method = "setupEncryption", at = @At("HEAD"), cancellable = true)
private void storeDecryptionCipher(Cipher decryptionCipher, Cipher encryptionCipher, CallbackInfo ci) {
if (this.viaFabricPlus$serverVersion != null /* This happens when opening a lan server and people are joining */ && this.viaFabricPlus$serverVersion.olderThanOrEquals(LegacyProtocolVersion.r1_6_4)) {
if (this.viaFabricPlus$serverVersion != null /* This happens when opening a lan server and people are joining */ && this.viaFabricPlus$serverVersion.olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
// Minecraft's encryption code is bad for us, we need to reorder the pipeline
ci.cancel();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public abstract class MixinClientLoginNetworkHandler {
@Inject(method = "joinServerSession", at = @At("HEAD"), cancellable = true)
public void onlyVerifySessionInOnlineMode(String serverId, CallbackInfoReturnable<Text> cir) {
final IClientConnection mixinClientConnection = (IClientConnection) connection;
if (mixinClientConnection.viaFabricPlus$getTargetVersion().olderThanOrEquals(LegacyProtocolVersion.r1_6_4)) {
if (mixinClientConnection.viaFabricPlus$getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
// We are in the 1.7 -> 1.6 protocol, so we need to skip the joinServer call
// if the server is in offline mode, due the packet changes <-> networking changes
// Minecraft's networking code is bad for us.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void setProtocolVersion(CallbackInfo ci) {
}

final boolean isCompatible;
if (version.olderThanOrEquals(LegacyProtocolVersion.r1_6_4)) {
if (version.olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
// Because of ViaVersion not supporting legacy minecraft versions where protocol ids are overlapping, ViaLegacy
// has its own protocol id offset, where realVersion = -(ViaLegacyVersion >> 2). Normally ViaVersion sends the client
// version to the client so its detection doesn't break when checking for serverVersion == clientVersion, but since
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public abstract class MixinAutoRefillHandler_ItemSlotMonitor {

@Inject(method = { "checkHandle", "checkShouldHandle" }, at = @At("HEAD"), cancellable = true)
public void dontHandleOffhandSlot(CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (currentSlotId == 45) ci.cancel();
}
}

@Inject(method = "updateCurrent", at = @At(value = "FIELD", target = "Lorg/anti_ad/mc/ipnext/event/AutoRefillHandler$ItemSlotMonitor;currentSlotId:I", shift = At.Shift.AFTER), cancellable = true)
public void dontUpdateCurrentOffhandSlot(CallbackInfo ci) {
if (ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
if (currentSlotId == 45) ci.cancel();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public abstract class MixinEntity {

@Redirect(method = "lithiumCollideMultiAxisMovement", at = @At(value = "INVOKE", target = "Ljava/lang/Math;abs(D)D", ordinal = 0))
private static double alwaysSortYXZ(double a) {
if (ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
return Double.MAX_VALUE;
} else {
return Math.abs(a);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public abstract class MixinAllowedAddressResolver {

@Inject(method = "resolve", at = @At("HEAD"), cancellable = true)
private void oldResolveBehaviour(ServerAddress address, CallbackInfoReturnable<Optional<Address>> cir) {
if (ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_16_4) || ProtocolHack.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) {
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4) || ProtocolHack.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) {
cir.setReturnValue(this.addressResolver.resolve(address));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public abstract class MixinBuiltChunk {

@Inject(method = "shouldBuild", at = @At("HEAD"), cancellable = true)
private void modifyRenderCondition(CallbackInfoReturnable<Boolean> cir) {
if (ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_8)) {
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
cir.setReturnValue(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private void clearMessages(DrawContext drawContext, int mouseX, int mouseY, Call

@Unique
private boolean viaFabricPlus$cancelTabComplete() {
return ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_12_2) && this.textField.getText().startsWith("/");
return ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2) && this.textField.getText().startsWith("/");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public abstract class MixinEnchantmentHelper {

@ModifyConstant(method = "getLevelFromNbt", constant = @Constant(intValue = 0))
private static int usePossibleMinLevel(int constant) {
if (ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_14_4)) {
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
return Short.MIN_VALUE;
} else {
return constant;
Expand All @@ -40,7 +40,7 @@ private static int usePossibleMinLevel(int constant) {

@ModifyConstant(method = "getLevelFromNbt", constant = @Constant(intValue = 255))
private static int usePossibleMaxLevel(int constant) {
if (ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_14_4)) {
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
return Short.MAX_VALUE;
} else {
return constant;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public abstract class MixinFlowableFluid {

@Redirect(method = "isFlowBlocked", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isSideSolidFullSquare(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;)Z"))
private boolean modifyIsSolidBlock(BlockState instance, BlockView blockView, BlockPos blockPos, Direction direction) {
if (ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_11_1)) {
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_11_1)) {
return Material1_19_4.getMaterial(instance).solid();
} else if (ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_13_2)) {
} else if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
final Block block = instance.getBlock();
if (block instanceof ShulkerBoxBlock || block instanceof LeavesBlock || block instanceof TrapdoorBlock ||
block == Blocks.BEACON || block == Blocks.CAULDRON || block == Blocks.GLASS ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public abstract class MixinGameOptions {

@ModifyVariable(method = "setServerViewDistance", at = @At("HEAD"), ordinal = 0, argsOnly = true)
private int changeServerViewDistance(int viewDistance) {
if (ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_17_1)) {
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_17_1)) {
return 0;
} else {
return viewDistance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public abstract class MixinKeyboardInput extends Input {

@ModifyVariable(method = "tick", at = @At(value = "LOAD", ordinal = 0), argsOnly = true)
private boolean changeSneakSlowdownCondition(boolean slowDown) {
if (ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_13_2)) {
if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
return this.sneaking;
} else if (ProtocolHack.getTargetVersion().olderThanOrEquals(ProtocolVersion.v1_14_4)) {
} else if (ProtocolHack.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) {
return !MinecraftClient.getInstance().player.isSpectator() && (this.sneaking || slowDown);
} else {
return slowDown;
Expand Down
Loading

0 comments on commit f151643

Please sign in to comment.