Package dan200.computercraft.api.detail
Class ComponentDetailProvider<T>
java.lang.Object
dan200.computercraft.api.detail.ComponentDetailProvider<T>
- Type Parameters:
T
- The type of the component's contents.
- All Implemented Interfaces:
DetailProvider<net.minecraft.core.component.DataComponentHolder>
public abstract class ComponentDetailProvider<T>
extends Object
implements DetailProvider<net.minecraft.core.component.DataComponentHolder>
An item detail provider for a specific data component on
ItemStack
s or
other DataComponentHolder
.-
Constructor Summary
ConstructorsConstructorDescriptionComponentDetailProvider
(@Nullable String namespace, net.minecraft.core.component.DataComponentType<T> component) Create a new component detail provider.ComponentDetailProvider
(net.minecraft.core.component.DataComponentType<T> component) Create a new component detail provider. -
Method Summary
Modifier and TypeMethodDescriptionabstract void
provideComponentDetails
(Map<? super String, Object> data, T component) Provide additional details for the given data component.final void
provideDetails
(Map<? super String, Object> data, net.minecraft.core.component.DataComponentHolder holder) Provide additional details for the given object.
-
Constructor Details
-
ComponentDetailProvider
public ComponentDetailProvider(@Nullable String namespace, net.minecraft.core.component.DataComponentType<T> component) Create a new component detail provider. Details will be inserted into a new sub-map named as pernamespace
.- Parameters:
namespace
- The namespace to use for this provider.component
- The data component to provide details for.
-
ComponentDetailProvider
Create a new component detail provider. Details will be inserted directly into the results.- Parameters:
component
- The data component to provide details for.
-
-
Method Details
-
provideComponentDetails
Provide additional details for the given data component. This method is called byturtle.getItemDetail()
. New properties should be added to the givenMap
,data
.This method is always called on the server thread, so it is safe to interact with the world here, but you should take care to avoid long blocking operations as this will stall the server and other computers.
- Parameters:
data
- The full details to be returned for this item stack. New properties should be added to this map.component
- The component to provide details for.
-
provideDetails
public final void provideDetails(Map<? super String, Object> data, net.minecraft.core.component.DataComponentHolder holder) Description copied from interface:DetailProvider
Provide additional details for the given object. This method is called by functions such asturtle.getItemDetail()
andturtle.inspect()
. New properties should be added to the givenMap
,data
.This method is always called on the server thread, so it is safe to interact with the world here, but you should take care to avoid long blocking operations as this will stall the server and other computers.
- Specified by:
provideDetails
in interfaceDetailProvider<T>
- Parameters:
data
- The full details to be returned. New properties should be added to this map.holder
- The object to provide details for.
-