Removed fixes which are now in VV

https://github.com/ViaVersion/ViaVersion/pull/4010
This commit is contained in:
RaphiMC 2024-07-07 18:20:33 +02:00
parent 864469aaac
commit a977ea519f
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94

View File

@ -23,8 +23,6 @@ import com.viaversion.viaversion.api.minecraft.HolderSet;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer; import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey; import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.item.data.FoodEffect;
import com.viaversion.viaversion.api.minecraft.item.data.FoodProperties;
import com.viaversion.viaversion.api.minecraft.item.data.ToolProperties; import com.viaversion.viaversion.api.minecraft.item.data.ToolProperties;
import com.viaversion.viaversion.api.minecraft.item.data.ToolRule; import com.viaversion.viaversion.api.minecraft.item.data.ToolRule;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
@ -46,8 +44,8 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.*; import java.util.*;
@ -60,9 +58,6 @@ public abstract class MixinBlockItemPacketRewriter1_20_5 extends ItemRewriter<Cl
@Unique @Unique
private final Map<String, Integer> armorMaxDamage_b1_8_1 = new HashMap<>(); private final Map<String, Integer> armorMaxDamage_b1_8_1 = new HashMap<>();
@Unique
private final Set<String> swordItems1_8 = new HashSet<>();
@Unique @Unique
private final Map<ProtocolVersion, Map<String, ToolProperties>> toolDataChanges = new LinkedHashMap<>(); private final Map<ProtocolVersion, Map<String, ToolProperties>> toolDataChanges = new LinkedHashMap<>();
@ -84,17 +79,9 @@ public abstract class MixinBlockItemPacketRewriter1_20_5 extends ItemRewriter<Cl
final JsonObject armorMaxDamages = ViaProxyMappingDataLoader.INSTANCE.loadData("armor-damages-b1.8.1.json"); final JsonObject armorMaxDamages = ViaProxyMappingDataLoader.INSTANCE.loadData("armor-damages-b1.8.1.json");
for (Map.Entry<String, JsonElement> entry : armorMaxDamages.entrySet()) { for (Map.Entry<String, JsonElement> entry : armorMaxDamages.entrySet()) {
final String item = entry.getKey(); this.armorMaxDamage_b1_8_1.put(entry.getKey(), entry.getValue().getAsInt());
final int maxDamage = entry.getValue().getAsInt();
this.armorMaxDamage_b1_8_1.put(item, maxDamage);
} }
this.swordItems1_8.add("minecraft:wooden_sword");
this.swordItems1_8.add("minecraft:stone_sword");
this.swordItems1_8.add("minecraft:iron_sword");
this.swordItems1_8.add("minecraft:golden_sword");
this.swordItems1_8.add("minecraft:diamond_sword");
ViaProxy.EVENT_MANAGER.registerRunnable(() -> { ViaProxy.EVENT_MANAGER.registerRunnable(() -> {
final JsonObject itemToolComponents = ViaProxyMappingDataLoader.INSTANCE.loadData("item-tool-components.json"); final JsonObject itemToolComponents = ViaProxyMappingDataLoader.INSTANCE.loadData("item-tool-components.json");
for (Map.Entry<String, JsonElement> entry : itemToolComponents.entrySet()) { for (Map.Entry<String, JsonElement> entry : itemToolComponents.entrySet()) {
@ -128,25 +115,26 @@ public abstract class MixinBlockItemPacketRewriter1_20_5 extends ItemRewriter<Cl
}, ViaLoadingEvent.class); }, ViaLoadingEvent.class);
} }
@Inject(method = "toStructuredItem", at = @At("RETURN")) @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 void appendItemDataFixComponents(UserConnection user, Item old, CallbackInfoReturnable<Item> cir) { private boolean changeSwordFixVersionRange(ProtocolVersion instance, ProtocolVersion other) {
final StructuredDataContainer data = cir.getReturnValue().dataContainer(); if (other == ProtocolVersion.v1_8) {
final String identifier = this.protocol.getMappingData().getFullItemMappings().identifier(cir.getReturnValue().identifier()); return instance.betweenInclusive(LegacyProtocolVersion.b1_8tob1_8_1, ProtocolVersion.v1_8);
if (user.getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(ProtocolVersion.v1_17_1)) { } else {
if (identifier.equals("minecraft:crossbow")) { return instance.olderThanOrEqualTo(other);
data.set(StructuredDataKey.MAX_DAMAGE, 326);
}
}
if (user.getProtocolInfo().serverProtocolVersion().betweenInclusive(LegacyProtocolVersion.b1_8tob1_8_1, ProtocolVersion.v1_8)) {
if (this.swordItems1_8.contains(identifier)) {
data.set(StructuredDataKey.FOOD1_20_5, new FoodProperties(0, 0F, true, 3600, null, new FoodEffect[0]));
} }
} }
@Inject(method = "appendItemDataFixComponents", at = @At("RETURN"))
private void appendItemDataFixComponents(UserConnection user, Item item, CallbackInfo ci) {
final StructuredDataContainer data = item.dataContainer();
final String identifier = this.protocol.getMappingData().getFullItemMappings().identifier(item.identifier());
if (user.getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) { if (user.getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
if (this.armorMaxDamage_b1_8_1.containsKey(identifier)) { if (this.armorMaxDamage_b1_8_1.containsKey(identifier)) {
data.set(StructuredDataKey.MAX_DAMAGE, this.armorMaxDamage_b1_8_1.get(identifier)); data.set(StructuredDataKey.MAX_DAMAGE, this.armorMaxDamage_b1_8_1.get(identifier));
} }
} }
if (user.getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_7tob1_7_3)) { if (user.getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_7tob1_7_3)) {
if (this.foodItems_b1_7_3.contains(identifier)) { if (this.foodItems_b1_7_3.contains(identifier)) {
data.set(StructuredDataKey.MAX_STACK_SIZE, 1); data.set(StructuredDataKey.MAX_STACK_SIZE, 1);