Contents
- Description
- Field Summary
- Constructor Summary
- Method Summary
- Field Details
- Constructor Details
- Method Details
- getComponentType()
- getItemStack()
- setItemStack(ItemStack)
- setPickupDelay(float)
- getPickupRadius(ComponentAccessor)
- getMergeRadius(ComponentAccessor)
- setMergeRadius(float)
- computeLifetimeSeconds(ComponentAccessor)
- computeDynamicLight()
- pollPickupDelay(float)
- pollPickupThrottle(float)
- pollMergeDelay(float)
- canPickUp()
- isRemovedByPlayerPickup()
- setRemovedByPlayerPickup(boolean)
- consumeNetworkOutdated()
- clone()
- generateItemDrops(ComponentAccessor, List, Vector3d, Rotation3fc)
- generateItemDrop(ComponentAccessor, ItemStack, Vector3d, Rotation3fc, float, float, float)
- generatePickedUpItem(Ref, ComponentAccessor, Ref, Vector3d)
- generatePickedUpItem(ItemStack, Vector3d, ComponentAccessor, Ref)
- addToItemContainer(Store, Ref, ItemContainer)
Class ItemComponent
java.lang.Object
com.hypixel.hytale.server.core.modules.entity.item.ItemComponent
- All Implemented Interfaces:
Component<EntityStore>, Cloneable
A component that represents an entity that has an affiliated item stack.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BuilderCodec<ItemComponent> The codec used to parseItemComponentinstances.static final floatThe default delay, in seconds, between attempting to merge with nearby stacks.static final floatThe default pickup delay, in seconds, for picking up items.static final floatThe pickup delay, in seconds, for items that are dropped.static final floatThe default delay, in seconds for pickup throttle.Fields inherited from interface Component
EMPTY_ARRAY -
Constructor Summary
ConstructorsConstructorDescriptionDefault Constructor for aItemComponentinstance.ItemComponent(ItemStack itemStack) Constructor for aItemComponentinstance with a default item stack value.ItemComponent(ItemStack itemStack, float mergeDelay, float pickupDelay, float pickupThrottle, boolean removedByPlayerPickup) Constructor for aItemComponentinstance with default parameters. -
Method Summary
Modifier and TypeMethodDescriptionstatic ItemStackaddToItemContainer(Store<EntityStore> store, Ref<EntityStore> itemRef, ItemContainer itemContainer) Called to add the contents of theItemStackof this component to the given containers.booleanDetermines whether this item can be picked up.clone()Called to compute the dynamic light value of this item component.floatcomputeLifetimeSeconds(ComponentAccessor<EntityStore> componentAccessor) Computes the lifetime of this item stack based on the config.booleanCalled to consume and return whether this item component is network outdated.static Holder<EntityStore> generateItemDrop(ComponentAccessor<EntityStore> accessor, ItemStack itemStack, org.joml.Vector3d position, Rotation3fc rotation, float velocityX, float velocityY, float velocityZ) Generates a single entity holder for an entity item based on the given item stack to be dropped.static Holder<EntityStore>[]generateItemDrops(ComponentAccessor<EntityStore> accessor, List<ItemStack> itemStacks, org.joml.Vector3d position, Rotation3fc rotation) Called to generate an array of entity item entity holders based on the provided item stacks.static Holder<EntityStore> generatePickedUpItem(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor, Ref<EntityStore> targetRef, org.joml.Vector3d targetPosition) Creates a new pick-up item entity based on the holder of the given item entity.static Holder<EntityStore> generatePickedUpItem(ItemStack itemStack, org.joml.Vector3d position, ComponentAccessor<EntityStore> componentAccessor, Ref<EntityStore> targetRef) Creates a new pick-up item entity based on the holder of the given item stack.static ComponentType<EntityStore, ItemComponent> floatgetMergeRadius(ComponentAccessor<EntityStore> componentAccessor) Fetches the merge radius for this item component.floatgetPickupRadius(ComponentAccessor<EntityStore> componentAccessor) Fetches the pickup radius for this item component.booleanbooleanpollMergeDelay(float dt) Called to poll the current merge delay of this item component.booleanpollPickupDelay(float dt) Called to poll the current pickup delay of this item component.booleanpollPickupThrottle(float dt) Called to poll the current pickup throttle of this item component.voidsetItemStack(ItemStack itemStack) Called to manually set theItemStackassociated with this item component.voidsetMergeRadius(float mergeRadius) Overrides the merge radius for this item component.voidsetPickupDelay(float pickupDelay) Called to manually set the pickup delay for this specific item component.voidsetRemovedByPlayerPickup(boolean removedByPlayerPickup) Called to set whether this item entity was removed due to player pickup.Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Component
cloneSerializable
-
Field Details
-
CODEC
The codec used to parseItemComponentinstances. -
DEFAULT_PICKUP_DELAY
public static final float DEFAULT_PICKUP_DELAYThe default pickup delay, in seconds, for picking up items.- See Also:
-
PICKUP_DELAY_DROPPED
public static final float PICKUP_DELAY_DROPPEDThe pickup delay, in seconds, for items that are dropped.- See Also:
-
PICKUP_THROTTLE
public static final float PICKUP_THROTTLEThe default delay, in seconds for pickup throttle.- See Also:
-
DEFAULT_MERGE_DELAY
public static final float DEFAULT_MERGE_DELAYThe default delay, in seconds, between attempting to merge with nearby stacks.- See Also:
-
-
Constructor Details
-
ItemComponent
public ItemComponent()Default Constructor for aItemComponentinstance. -
ItemComponent
Constructor for aItemComponentinstance with a default item stack value.- Parameters:
itemStack- TheItemStackinstance for this item component.
-
ItemComponent
public ItemComponent(@Nullable ItemStack itemStack, float mergeDelay, float pickupDelay, float pickupThrottle, boolean removedByPlayerPickup) Constructor for aItemComponentinstance with default parameters.- Parameters:
itemStack- TheItemStackinstance for this item component.mergeDelay- The configured merge delay, in seconds.pickupDelay- The pickup delay, in seconds.pickupThrottle- The pickup throttle, in seconds.removedByPlayerPickup- Whether this item has been removed via player pickup.
-
-
Method Details
-
getComponentType
- Returns:
- the
ItemComponentcomponent type.
-
getItemStack
-
setItemStack
-
setPickupDelay
public void setPickupDelay(float pickupDelay) Called to manually set the pickup delay for this specific item component.- Parameters:
pickupDelay- The delay, in seconds, to set.
-
getPickupRadius
Fetches the pickup radius for this item component.- Parameters:
componentAccessor- The component store for component access.- Returns:
- the pickup radius of this item component.
-
getMergeRadius
Fetches the merge radius for this item component.- Parameters:
componentAccessor- The component store for component access.- Returns:
- the merge radius of this item component.
-
setMergeRadius
public void setMergeRadius(float mergeRadius) Overrides the merge radius for this item component.Pass a negative value to clear the override. The next call to
getMergeRadius(ComponentAccessor)then refetches the value from the item and world config.- Parameters:
mergeRadius- The merge radius to set.
-
computeLifetimeSeconds
Computes the lifetime of this item stack based on the config.- Parameters:
componentAccessor- The component store for component access.- Returns:
- The time in seconds this item should live for or null to never despawn.
-
computeDynamicLight
Called to compute the dynamic light value of this item component.- Returns:
- the computed
ColorLightvalue, if available.
-
pollPickupDelay
public boolean pollPickupDelay(float dt) Called to poll the current pickup delay of this item component.- Parameters:
dt- The delta time of the current tick.- Returns:
trueif the pickup throttle has concluded,falseotherwise.
-
pollPickupThrottle
public boolean pollPickupThrottle(float dt) Called to poll the current pickup throttle of this item component.- Parameters:
dt- The delta time of the current tick.- Returns:
trueif the pickup throttle has concluded,falseotherwise.
-
pollMergeDelay
public boolean pollMergeDelay(float dt) Called to poll the current merge delay of this item component.- Parameters:
dt- The delta time of the current tick.- Returns:
trueif the delay has concluded,falseotherwise.
-
canPickUp
public boolean canPickUp()Determines whether this item can be picked up.- Returns:
trueif it can be picked up,falseotherwise.
-
isRemovedByPlayerPickup
public boolean isRemovedByPlayerPickup()- Returns:
trueif the item was removed by player pickup,falseotherwise.
-
setRemovedByPlayerPickup
public void setRemovedByPlayerPickup(boolean removedByPlayerPickup) Called to set whether this item entity was removed due to player pickup.- Parameters:
removedByPlayerPickup- Whether this item entity was removed due to player pickup.
-
consumeNetworkOutdated
public boolean consumeNetworkOutdated()Called to consume and return whether this item component is network outdated.- Returns:
trueif outdated,falseotherwise.
-
clone
- Specified by:
clonein interfaceComponent<EntityStore>- Returns:
- a clone instance of the original component instance.
-
generateItemDrops
@Nonnull public static Holder<EntityStore>[] generateItemDrops(@Nonnull ComponentAccessor<EntityStore> accessor, @Nonnull List<ItemStack> itemStacks, @Nonnull org.joml.Vector3d position, @Nonnull Rotation3fc rotation) Called to generate an array of entity item entity holders based on the provided item stacks.- Parameters:
accessor- TheComponentAccessorfor entity store access.itemStacks- The collection ofItemStackinstances to be dropped.position- The position to drop the item stacks around.rotation- The rotation of the dropped items.- Returns:
- the array of entity holders for the newly created entity items.
-
generateItemDrop
@Nullable public static Holder<EntityStore> generateItemDrop(@Nonnull ComponentAccessor<EntityStore> accessor, @Nullable ItemStack itemStack, @Nonnull org.joml.Vector3d position, @Nonnull Rotation3fc rotation, float velocityX, float velocityY, float velocityZ) Generates a single entity holder for an entity item based on the given item stack to be dropped.- Parameters:
accessor- TheComponentAccessorfor entity store access.itemStack- TheItemStackinstance that is to be dropped.position- The position to drop the item stack at.rotation- The rotation to be applied during the dropping.velocityX- The X velocity of the drop.velocityY- The Y velocity of the drop.velocityZ- The Z velocity of the drop.- Returns:
- the newly created entity holder for the item entity.
-
generatePickedUpItem
@Nullable public static Holder<EntityStore> generatePickedUpItem(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor, @Nonnull Ref<EntityStore> targetRef, @Nonnull org.joml.Vector3d targetPosition) Creates a new pick-up item entity based on the holder of the given item entity.- Parameters:
ref- The entity reference of the original item entity.componentAccessor- The command buffer for component access.targetRef- The entity reference of the target entity.targetPosition- The position of the target entity.- Returns:
- the entity store
Holderof the pickup item entity.
-
generatePickedUpItem
@Nonnull public static Holder<EntityStore> generatePickedUpItem(@Nonnull ItemStack itemStack, @Nonnull org.joml.Vector3d position, @Nonnull ComponentAccessor<EntityStore> componentAccessor, @Nonnull Ref<EntityStore> targetRef) Creates a new pick-up item entity based on the holder of the given item stack.- Parameters:
itemStack- TheItemStackinstance to be picked up.position- The position to spawn the pick-up item entity at.componentAccessor- The command buffer for component access.targetRef- The entity reference of the target entity.- Returns:
- the entity store
Holderof the pickup item entity.
-
addToItemContainer
@Nullable public static ItemStack addToItemContainer(@Nonnull Store<EntityStore> store, @Nonnull Ref<EntityStore> itemRef, @Nonnull ItemContainer itemContainer) Called to add the contents of theItemStackof this component to the given containers.- Parameters:
store- The entity store for component access.itemRef- The ref of the item entity.itemContainer- The item containers to add to.- Returns:
- the remaining
ItemStackinstance, ornullif the full stack was consumed.
-