Skip to content

Commit

Permalink
Update VV API usage
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed Dec 9, 2024
1 parent 75cf57a commit 5b677af
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.*;
Expand Down Expand Up @@ -118,15 +117,6 @@ private void loadItemMappings(Protocol1_20_3To1_20_5 protocol, CallbackInfo ci)
});
}

@Redirect(method = "appendItemDataFixComponents", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;olderThanOrEqualTo(Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;)Z"))
private boolean changeSwordFixVersionRange(ProtocolVersion instance, ProtocolVersion other) {
if (other == ProtocolVersion.v1_8) {
return instance.betweenInclusive(LegacyProtocolVersion.b1_8tob1_8_1, ProtocolVersion.v1_8);
} else {
return instance.olderThanOrEqualTo(other);
}
}

// Older servers don't have these components, so we can use them to emulate old item behaviour without the need
// of modifying tons of code in the game.
@Inject(method = "appendItemDataFixComponents", at = @At("RETURN"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion;

import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.protocols.v1_21to1_21_2.rewriter.BlockItemPacketRewriter1_21_2;
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.rewriter.BlockItemPacketRewriter1_21_4;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(value = BlockItemPacketRewriter1_21_2.class, remap = false)
public abstract class MixinBlockItemPacketRewriter1_21_2 {
@Mixin(value = BlockItemPacketRewriter1_21_4.class, remap = false)
public abstract class MixinBlockItemPacketRewriter1_21_4 {

@Redirect(method = "appendItemDataFixComponents", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;olderThanOrEqualTo(Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;)Z"))
private boolean changeSwordFixVersionRange(ProtocolVersion instance, ProtocolVersion other) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/viafabricplus.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"fixes.minecraft.entity.MixinItemEntity",
"fixes.minecraft.entity.MixinLivingEntity",
"fixes.minecraft.entity.MixinMobEntity",
"fixes.minecraft.entity.MixinMooshroomEntity",
"fixes.minecraft.entity.MixinOtherClientPlayerEntity",
"fixes.minecraft.entity.MixinPlayerEntity",
"fixes.minecraft.entity.MixinPlayerEntityRenderer",
Expand Down Expand Up @@ -191,7 +192,7 @@
"fixes.vialegacy.MixinProtocolc0_30cpeToc0_28_30",
"fixes.vialegacy.MixinProtocolr1_7_6_10Tor1_8",
"fixes.viaversion.MixinBlockItemPacketRewriter1_20_5",
"fixes.viaversion.MixinBlockItemPacketRewriter1_21_2",
"fixes.viaversion.MixinBlockItemPacketRewriter1_21_4",
"fixes.viaversion.MixinCommandBlockProvider",
"fixes.viaversion.MixinCommonBoss",
"fixes.viaversion.MixinEntityPacketRewriter1_12",
Expand Down Expand Up @@ -220,13 +221,12 @@
"fixes.viaversion.MixinWorldPacketRewriter1_19",
"viabedrock.MixinJoinPackets",
"vialegacy.MixinExtensionProtocolMetadataStorage",
"vialegacy.MixinViaLegacyConfig",
"fixes.minecraft.entity.MixinMooshroomEntity"
"vialegacy.MixinViaLegacyConfig"
],
"injectors": {
"defaultRequire": 1
},
"overwrites": {
"requireAnnotations": true
}
}
}

0 comments on commit 5b677af

Please sign in to comment.