Code cleanup

This commit is contained in:
RaphiMC 2024-04-28 14:44:50 +02:00
parent f45895c547
commit a6fd03ded2
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94
4 changed files with 8 additions and 4 deletions

View File

@ -20,7 +20,10 @@
package de.florianmichael.viafabricplus.fixes;
import com.viaversion.viaversion.api.protocol.AbstractSimpleProtocol;
import com.viaversion.viaversion.api.protocol.packet.*;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundPackets1_20_5;
@ -104,5 +107,6 @@ public class VFPProtocol extends AbstractSimpleProtocol {
interface PacketReader {
void read(PacketWrapper wrapper) throws Exception;
}
}

View File

@ -34,7 +34,7 @@ public abstract class MixinDrawContext {
@Redirect(method = "drawItemInSlot(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getCount()I"))
private int handleNegativeItemCount(ItemStack instance) {
final NbtCompound tag = ItemUtil.getOrNull(instance);
final NbtCompound tag = ItemUtil.getTagOrNull(instance);
if (tag != null && tag.contains(ClientsideFixes.ITEM_COUNT_FIX_KEY)) {
return tag.getInt(ClientsideFixes.ITEM_COUNT_FIX_KEY);
} else {

View File

@ -62,7 +62,7 @@ public abstract class MixinItemStack {
return;
}
final NbtCompound tag = ItemUtil.getOrNull((ItemStack) (Object) this);
final NbtCompound tag = ItemUtil.getTagOrNull((ItemStack) (Object) this);
if (tag == null) {
return;
}

View File

@ -26,7 +26,7 @@ import net.minecraft.nbt.NbtCompound;
public class ItemUtil {
// Via 1.20.5->.3 will always put the original item data into CUSTOM_DATA if it's not empty.
public static NbtCompound getOrNull(final ItemStack stack) {
public static NbtCompound getTagOrNull(final ItemStack stack) {
if (!stack.contains(DataComponentTypes.CUSTOM_DATA)) {
return null;
}