mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2025-01-04 18:47:48 +01:00
parent
57ba542470
commit
a15b2f586f
@ -22,11 +22,16 @@ import com.viaversion.nbt.tag.CompoundTag;
|
|||||||
import com.viaversion.nbt.tag.ListTag;
|
import com.viaversion.nbt.tag.ListTag;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.ModifierData;
|
import com.viaversion.viaversion.api.minecraft.item.data.ModifierData;
|
||||||
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_8;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ServerboundPackets1_9;
|
||||||
import com.viaversion.viaversion.protocols.v1_8to1_9.rewriter.ItemPacketRewriter1_9;
|
import com.viaversion.viaversion.protocols.v1_8to1_9.rewriter.ItemPacketRewriter1_9;
|
||||||
|
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||||
import com.viaversion.viaversion.util.Pair;
|
import com.viaversion.viaversion.util.Pair;
|
||||||
import net.raphimc.viaproxy.protocoltranslator.impl.ViaProxyMappingDataLoader;
|
import net.raphimc.viaproxy.protocoltranslator.impl.ViaProxyMappingDataLoader;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@ -41,7 +46,7 @@ import java.util.Map;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Mixin(value = ItemPacketRewriter1_9.class, remap = false)
|
@Mixin(value = ItemPacketRewriter1_9.class, remap = false)
|
||||||
public abstract class MixinItemPacketRewriter1_9 {
|
public abstract class MixinItemPacketRewriter1_9 extends ItemRewriter<ClientboundPackets1_8, ServerboundPackets1_9, Protocol1_8To1_9> {
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private final Int2ObjectMap<String> itemIdentifiers = new Int2ObjectOpenHashMap<>();
|
private final Int2ObjectMap<String> itemIdentifiers = new Int2ObjectOpenHashMap<>();
|
||||||
@ -49,8 +54,9 @@ public abstract class MixinItemPacketRewriter1_9 {
|
|||||||
@Unique
|
@Unique
|
||||||
private final Map<String, Map<String, Pair<String, ModifierData>>> itemAttributes = new HashMap<>();
|
private final Map<String, Map<String, Pair<String, ModifierData>>> itemAttributes = new HashMap<>();
|
||||||
|
|
||||||
@Unique
|
public MixinItemPacketRewriter1_9(Protocol1_8To1_9 protocol, Type<Item> itemType, Type<Item[]> itemArrayType, Type<Item> mappedItemType, Type<Item[]> mappedItemArrayType) {
|
||||||
private final String attributeFixTagName = "VV|AttributeFix";
|
super(protocol, itemType, itemArrayType, mappedItemType, mappedItemArrayType);
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "<init>", at = @At("RETURN"))
|
@Inject(method = "<init>", at = @At("RETURN"))
|
||||||
private void loadAdditionalData(CallbackInfo ci) {
|
private void loadAdditionalData(CallbackInfo ci) {
|
||||||
@ -89,7 +95,7 @@ public abstract class MixinItemPacketRewriter1_9 {
|
|||||||
item.setTag(tag);
|
item.setTag(tag);
|
||||||
attributeFixTag.putBoolean("RemoveTag", true);
|
attributeFixTag.putBoolean("RemoveTag", true);
|
||||||
}
|
}
|
||||||
tag.put(this.attributeFixTagName, attributeFixTag);
|
tag.put(nbtTagName("attributeFix"), attributeFixTag);
|
||||||
|
|
||||||
ListTag<CompoundTag> attributeModifiers = tag.getListTag("AttributeModifiers", CompoundTag.class);
|
ListTag<CompoundTag> attributeModifiers = tag.getListTag("AttributeModifiers", CompoundTag.class);
|
||||||
if (attributeModifiers == null) {
|
if (attributeModifiers == null) {
|
||||||
@ -117,7 +123,7 @@ public abstract class MixinItemPacketRewriter1_9 {
|
|||||||
if (item == null) return;
|
if (item == null) return;
|
||||||
final CompoundTag tag = item.tag();
|
final CompoundTag tag = item.tag();
|
||||||
if (tag == null) return;
|
if (tag == null) return;
|
||||||
final CompoundTag attributeFixTag = tag.removeUnchecked(attributeFixTagName);
|
final CompoundTag attributeFixTag = tag.removeUnchecked(nbtTagName("attributeFix"));
|
||||||
if (attributeFixTag == null) return;
|
if (attributeFixTag == null) return;
|
||||||
|
|
||||||
if (attributeFixTag.contains("RemoveAttributeModifiers")) {
|
if (attributeFixTag.contains("RemoveAttributeModifiers")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user