Skip to content

Transfur Variants

LtxPgm edited this page Dec 3, 2024 · 5 revisions

Overview

The concept of what a player can transfur into is called a "transfur variant", or just "variant". TransfurVariant<T> is a generic class that represents a possible transfur variant, and has properties that apply to the player when they have said variant. T extends a ChangedEntity which is a specialized entity, with additional specifiable parameters and functions. TransfurVariantInstance<T> is an instantiated version of TransfurVariant<T> and contains "live" data, such as a instanced ChangedEntity, instanced abilities, and other stat tracking info.

Within TransfurVariant<T> is a Builder<T> class that assists in registration of the variant. Most builder fields are self-explanatory, but are documented here as well. Here is an example:

TransfurVariant.Builder.of(ChangedEntities.DARK_LATEX_WOLF_MALE) // The constructor `of()` takes a registry entry for EntityType<T>
    .stepSize(0.7f) // This sets the player's stepSize, defaulted at 0.6f
    .faction(LatexType.DARK_LATEX) // Specifies the variant's faction. See documentation of LatexType for more information.
    .build(); // Finalizes, and creates a TransfurVariant<T>

TransfurVariant.Builder.of(ChangedEntities.LATEX_TIGER_SHARK) // Start with the tiger shark entity type
    .gills() // This sets the player can breathe underwater, and on land
    .addAbility(ChangedAbilities.SUMMON_SHARKS) // This gives the player the ability to summon sharks
    .build() // Finalizes

When the player is transfurred into this variant, they will:

  • Adopt the EntityType<T>'s base attributes,
  • Have a step size of 0.7, and
  • Be aligned to fellow dark latexes.

Transfur Variant Builder Properties

  • faction(LatexType) - Specifies the player's alignment, default: LatexType.NEUTRAL. See LatexType
  • jumpStrength(float) - Multiplies the player's jump height, default: 1.0
  • breatheMode(BreatheMode)/gills() - Specifies how the player breathes. See BreatheMode
  • reducedFall() - The player will take less fall damage
  • canClimb() - The player can climb walls, ignore cobwebs
  • scares(Class<E>) - Adds to a list of entities the player scares away
  • stepSize(float) - How many blocks up the player will step, default: 0.6
  • glide() - The player has wings and can creative fly (nerfed), and can fall fly (elytra)
  • extraJumps(int)/doubleJump() - How many times the player can jump mid-air, default: 0
  • transfurMode(TransfurMode)/absorbing()/replicating() - How the player transfur other entities. See TransfurMode
  • visionType(VisionType)/nightVision() - How the player sees, See VisionType
  • noLegs()/quadrupedal() - What kind of armor the player can wear. See Armor Types
  • itemuseMode(UseItemMode)/disableItems()/holdItemsInMouth() - How the player interacts with their items. See UseItemMode
  • cameraZOffset(float) - How far the player's camera is offset from the center, default: 0.0
  • sound(ResourceLocation) - What sound plays when they are transfurred, default: "changed:poison"
  • addAbility(Supplier<AbstractAbility>) - Adds an ability the player can use. See AbstractAbility

Breathe Mode

TransfurVariant.BreatheMode is an enum that describes how an entity breathes, and has the following values:

  • NORMAL - Vanilla player breathing behavior
  • WEAK - Player holds less air in water
  • STRONG - Player holds more air in water
  • WATER - Player can only breathe water
  • ANY - Player can breathe both air and water

If the player's BreatheMode can breathe water, they will have the aqua affinity effect (underwater mining speed).

Vision Type

VisionType is an enum that describes how an entity sees, and has the following values:

  • NORMAL - Vanilla eyesight, with no additional effects
  • NIGHT_VISION - Player can see in the dark, and gives the night vision effect
  • BLIND - Player cannot see well, and gives the blindness effect
  • REDUCED - Player has overlay effect on their screen, with no additional effects

Transfur Mode

TransfurMode is an enum that describes how an entity transfur other entities:

  • REPLICATION - The entity clones itself onto the victim using it's getTransfurVariant() function in ChangedEntity
  • ABSORPTION - The entity takes over the victim, healing a significant amount
  • NONE - The entity cannot transfur, follows vanilla damage behavior

Use Item Mode

UseItemMode is an extensible enum (IExtensibleEnum) that describes how an entity may use their items/hands:

  • NORMAL - Vanilla item/hand behavior
  • MOUTH - Entity can only hold one item out, and can't break blocks (Used with the Dark Latex Wolf Pup)
  • NONE - Entity cannot hold items out, break blocks, attack entities, nor interact with blocks

Registration

Transfur variants are game objects like items/entities/blocks. They must be registered to the changed:latex_variant registry key, accessible with ChangedRegistry.TRANSFUR_VARIANT. It's recommended to use Forge's DeferredRegister to handle registering your variants, accessible with ChangedRegistry.TRANSFUR_VARIANT.createDeferred(modId).

Checking for Transfur Variant

Since we need to know what the player is transfurred as a lot, there are some helper functions to work with.

// Returns the player's transfur variant, or null
ProcessTransfur.getPlayerTransfurVariant(player);

// Returns an optional wrapping the player's transfur variant, or empty
ProcessTransfur.getPlayerTransfurVariantSafe(player);

ProcessTransfur.ifPlayerTransfurred(player, variant -> {
    // This code executes if the player is transfurred
    // variant is the player's TransfurVariantInstance<?>
});

Clone this wiki locally