Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fabric/src/main/resource-templates/fabric.mod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ custom:
net/minecraft/class_2960: [ net/kyori/adventure/key/Key ] # net/minecraft/resources/ResourceLocation
net/minecraft/class_3414: [ net/kyori/adventure/sound/Sound<%= '$' %>Type ] # net/minecraft/sounds/SoundEvent
net/minecraft/class_5321: [ net/kyori/adventure/key/Keyed ] # net/minecraft/resources/ResourceKey
net/minecraft/class_1799: [ "net/kyori/adventure/text/event/HoverEventSource<Lnet/kyori/adventure/text/event/HoverEvent<%= '$' %>ShowItem;>" ] # net/minecraft/world/item/ItemStack # generic?
net/minecraft/class_1799: [ net/kyori/adventure/platform/modcommon/ItemHoverEventSource ] # net/minecraft/world/item/ItemStack # generic?
net/minecraft/class_7469: [ net/kyori/adventure/chat/SignedMessage<%= '$' %>Signature ] # net/minecraft/network/chat/MessageSignature

depends:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package net.kyori.adventure.platform.modcommon;

import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.event.HoverEvent.ShowItem;
import net.kyori.adventure.text.event.HoverEventSource;
import org.jetbrains.annotations.NotNull;

import java.util.function.UnaryOperator;

/**
* Marker interface for item hover event sources.
* Used by interface injection on {@link net.minecraft.world.item.ItemStack}.
*/
public interface ItemHoverEventSource extends HoverEventSource<ShowItem> {

@Override
default HoverEvent<ShowItem> asHoverEvent(@NotNull UnaryOperator<ShowItem> op) {
throw new UnsupportedOperationException("Method must be overridden by Mixin");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,11 @@
*/
package net.kyori.adventure.platform.modcommon.impl.mixin.minecraft.world.item;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.function.UnaryOperator;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.platform.modcommon.ItemHoverEventSource;
import net.kyori.adventure.platform.modcommon.impl.nbt.ModDataComponentValue;
import net.kyori.adventure.text.event.DataComponentValue;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.event.HoverEventSource;
import net.minecraft.core.component.DataComponentPatch;
import net.minecraft.core.component.DataComponentType;
import net.minecraft.core.registries.BuiltInRegistries;
Expand All @@ -42,8 +37,14 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.function.UnaryOperator;

@Mixin(ItemStack.class)
public abstract class ItemStackMixin implements HoverEventSource<HoverEvent.ShowItem> {
public abstract class ItemStackMixin implements ItemHoverEventSource {
// @formatter:off
@Shadow public abstract int shadow$getCount();
@Shadow public abstract Item shadow$getItem();
Expand Down
5 changes: 5 additions & 0 deletions neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ neoForge {
sourceSet(sourceSets.main.get())
}
}

interfaceInjectionData {
from(file("interfaces.json"))
publish(file("interfaces.json"))
}
}

configurations.jarJar {
Expand Down
39 changes: 39 additions & 0 deletions neoforge/interfaces.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"net/minecraft/commands/CommandSourceStack": [
"net/kyori/adventure/platform/modcommon/AdventureCommandSourceStack"
],
"net/minecraft/world/entity/Entity": [
"net/kyori/adventure/sound/Sound$Emitter",
"net/kyori/adventure/platform/modcommon/EntityHoverEventSource"
],
"net/minecraft/server/MinecraftServer": [
"net/kyori/adventure/audience/Audience"
],
"net/minecraft/world/entity/player/Player": [
"net/kyori/adventure/platform/modcommon/IdentifiedAtRuntime"
],
"net/minecraft/server/rcon/RconConsoleSource": [
"net/kyori/adventure/audience/Audience"
],
"net/minecraft/server/level/ServerPlayer": [
"net/kyori/adventure/audience/Audience"
],
"net/minecraft/client/player/LocalPlayer": [
"net/kyori/adventure/audience/Audience"
],
"net/minecraft/resources/ResourceLocation": [
"net/kyori/adventure/key/Key"
],
"net/minecraft/sounds/SoundEvent": [
"net/kyori/adventure/sound/Sound$Type"
],
"net/minecraft/resources/ResourceKey": [
"net/kyori/adventure/key/Keyed"
],
"net/minecraft/world/item/ItemStack": [
"net/kyori/adventure/platform/modcommon/ItemHoverEventSource"
],
"net/minecraft/network/chat/MessageSignature": [
"net/kyori/adventure/chat/SignedMessage$Signature"
]
}