Class IMaterialMirror

java.lang.Object
com.saicone.rtag.item.mirror.IMaterialMirror
All Implemented Interfaces:
ItemMirror

public class IMaterialMirror extends Object implements ItemMirror
IMaterialMirror to convert item material IDs across version.
This is probably the most complex mirror instance in Rtag.
See Also:
  • Constructor Details

    • IMaterialMirror

      public IMaterialMirror()
      Constructs an simple IMaterialMirror with cache duration of 3 hours.
    • IMaterialMirror

      public IMaterialMirror(long duration, @NotNull @NotNull TimeUnit unit, @NotNull @NotNull String defaultMaterial)
      Constructs an IMaterialMirror with specified parameters.
      Parameters:
      duration - Cache duration.
      unit - Time unit for cache.
      defaultMaterial - Default material for incompatible IDs.
  • Method Details

    • upgrade

      public void upgrade(@NotNull @NotNull Object compound, @NotNull @NotNull String id, @NotNull @NotNull com.saicone.rtag.util.MC from, @NotNull @NotNull com.saicone.rtag.util.MC to)
      Description copied from interface: ItemMirror
      Upgrade current item tag compound from lower version.
      Specified by:
      upgrade in interface ItemMirror
      Parameters:
      compound - the tag compound that represents item data.
      id - the item material id.
      from - the initial version of item data.
      to - the version to upgrade item data.
    • upgrade

      public void upgrade(@NotNull @NotNull Object compound, @NotNull @NotNull String id, @NotNull @NotNull Object components, @NotNull @NotNull com.saicone.rtag.util.MC from, @NotNull @NotNull com.saicone.rtag.util.MC to)
      Description copied from interface: ItemMirror
      Upgrade current item tag compound from lower version.
      Specified by:
      upgrade in interface ItemMirror
      Parameters:
      compound - the tag compound that represents item data.
      id - the item material id.
      components - the item components, on older versions this may be the item tag.
      from - the initial version of item data.
      to - the version to upgrade item data.
    • downgrade

      public void downgrade(@NotNull @NotNull Object compound, @NotNull @NotNull String id, @NotNull @NotNull com.saicone.rtag.util.MC from, @NotNull @NotNull com.saicone.rtag.util.MC to)
      Description copied from interface: ItemMirror
      Downgrade current item tag compound from upper version.
      Specified by:
      downgrade in interface ItemMirror
      Parameters:
      compound - the tag compound that represents item data.
      id - the item material id.
      from - the initial version of item data.
      to - the version to downgrade item data.
    • downgrade

      public void downgrade(@NotNull @NotNull Object compound, @NotNull @NotNull String id, @NotNull @NotNull Object components, @NotNull @NotNull com.saicone.rtag.util.MC from, @NotNull @NotNull com.saicone.rtag.util.MC to)
      Description copied from interface: ItemMirror
      Downgrade current item tag compound from upper version.
      Specified by:
      downgrade in interface ItemMirror
      Parameters:
      compound - the tag compound that represents item data.
      id - the item material id.
      components - the item components, on older versions this may be the item tag.
      from - the initial version of item data.
      to - the version to downgrade item data.
    • resolveSaved

      @Internal public void resolveSaved(@NotNull @NotNull Object compound, @NotNull @NotNull String id, int damage, @NotNull @NotNull Object components, @NotNull @NotNull com.saicone.rtag.util.MC from, @NotNull @NotNull com.saicone.rtag.util.MC to)
      Resolve an ItemStack if it contains "savedID" inside custom data component.
      Parameters:
      compound - the tag compound that represent item data.
      id - the id of the item.
      damage - the item damage amount.
      components - the item components, on older versions this can be item tag.
      from - the original version from item.
      to - the version to convert item.
    • resolveMaterial

      @Internal public void resolveMaterial(@NotNull @NotNull Object compound, @NotNull @NotNull String id, int damage, @Nullable @Nullable Object components, @NotNull @NotNull com.saicone.rtag.util.MC from, @NotNull @NotNull com.saicone.rtag.util.MC to)
      Resolve material of the item, this method checks if the ID needs to be converted.
      Parameters:
      compound - item representation as CompoundTag.
      id - ID of the item.
      damage - Damage amount.
      components - Item components.
      from - Version specified in compound.
      to - Version to convert.
    • resolveItem

      @Internal public void resolveItem(@NotNull @NotNull Object compound, @NotNull ItemMaterialTag.Data material, @Nullable @Nullable Object components, @NotNull @NotNull com.saicone.rtag.util.MC from, @NotNull @NotNull com.saicone.rtag.util.MC to)
      Resolver current item compound with new material to set.
      Parameters:
      compound - Item CompoundTag.
      material - Material to set.
      components - Item components.
      from - Version specified in compound.
      to - Version to convert.
    • setDamage

      @Internal public void setDamage(@NotNull @NotNull Object compound, @Nullable @Nullable Object components, int damage, @NotNull @NotNull com.saicone.rtag.util.MC from, @NotNull @NotNull com.saicone.rtag.util.MC to)
      Set item damage depending on item version, this method removes old damage tag if the conversion is across legacy-flat.
      Parameters:
      compound - Item CompoundTag.
      components - Item components.
      damage - Damage amount to set.
      from - Version specified in compound
      to - Version to convert.
    • getDamage

      @Internal public int getDamage(@NotNull @NotNull Object compound, @Nullable @Nullable Object components, @NotNull @NotNull com.saicone.rtag.util.MC version)
      Get current item damage depending on item version.
      Parameters:
      compound - Item CompoundTag.
      components - Item components.
      version - Version of the item.
      Returns:
      A integer representing item damage.
    • getEggEntity

      @NotNull @Internal public @NotNull String getEggEntity(@NotNull @NotNull Object compound, @NotNull @NotNull com.saicone.rtag.util.MC version)
      Get current item entity, method for legacy SPAWN_EGG items.
      Parameters:
      compound - Item CompoundTag.
      version - Item version
      Returns:
      A string representing entity id.
    • translate

      @NotNull @Internal public ItemMaterialTag.Data translate(@NotNull ItemMaterialTag.Data material, @NotNull @NotNull com.saicone.rtag.util.MC from, @NotNull @NotNull com.saicone.rtag.util.MC to)
      Translate given material and version pair into current server version.
      Parameters:
      material - Material to translate.
      from - Version specified in compound
      to - Version to convert.
      Returns:
      A string representing current server version material.
    • resolveSaved

      @Deprecated(since="1.5.14", forRemoval=true) public void resolveSaved(Object compound, String id, int damage, Object components, float from, float to)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Resolve an ItemStack if it contains "savedID" inside custom data component.
      Parameters:
      compound - Item CompoundTag.
      id - ID of the item.
      damage - Damage amount.
      components - Item components.
      from - Version specified in compound.
      to - Version to convert.
    • resolveMaterial

      @Deprecated(since="1.5.14", forRemoval=true) public void resolveMaterial(Object compound, String id, int damage, Object components, float from, float to)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Resolve material of the item, this method checks if the ID needs to be converted.
      Parameters:
      compound - Item CompoundTag.
      id - ID of the item.
      damage - Damage amount.
      components - Item components.
      from - Version specified in compound.
      to - Version to convert.
    • resolveItem

      @Deprecated(since="1.5.14", forRemoval=true) public void resolveItem(Object compound, String material, Object components, float from, float to)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Resolver current item compound with new material to set.
      Parameters:
      compound - Item CompoundTag.
      material - Material to set.
      components - Item components.
      from - Version specified in compound.
      to - Version to convert.
    • setDamage

      @Deprecated(since="1.5.14", forRemoval=true) public void setDamage(Object compound, Object components, int damage, float from, float to)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set item damage depending on item version, this method removes old damage tag if the conversion is across legacy-flat.
      Parameters:
      compound - Item CompoundTag.
      components - Item components.
      damage - Damage amount to set.
      from - Version specified in compound
      to - Version to convert.
    • getDamage

      @Deprecated(since="1.5.14", forRemoval=true) public int getDamage(Object compound, Object components, float version)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get current item damage depending on item version.
      Parameters:
      compound - Item CompoundTag.
      components - Item components.
      version - Version of the item.
      Returns:
      A integer representing item damage.
    • getEggEntity

      @Deprecated(since="1.5.14", forRemoval=true) public String getEggEntity(Object compound, float version)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get current item entity, method for legacy SPAWN_EGG items.
      Parameters:
      compound - Item CompoundTag.
      version - Item version
      Returns:
      A string representing entity id.
    • translate

      @Deprecated(since="1.5.14", forRemoval=true) public String translate(String material, float from, float to)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Translate given material and version pair into current server version.
      Parameters:
      material - Material to translate.
      from - Version specified in compound
      to - Version to convert.
      Returns:
      A string representing current server version material.