Class BlockToMaterialBinding

java.lang.Object
etithespirit.orimod.spiritmaterial.BlockToMaterialBinding

public final class BlockToMaterialBinding extends Object
A custom binding from block to material that may not necessarily use the Block's defined material.
If a block is not defined in this class to have a custom material, then the material it was constructed with is used.
Author:
Eti
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    associateMCMaterialWith(net.minecraft.world.level.material.Material mtl, SpiritMaterial smtl)
    Associates the given Minecraft or Mod Material with the given SpiritMaterial
    static net.minecraft.world.level.block.state.BlockState
    getAppropriateMaterialBetween(net.minecraft.world.level.block.state.BlockState blockStandingOn, net.minecraft.world.level.block.state.BlockState blockStandingIn)
    Given two blockstates, this determines which state should be used to grab the material from.
    getMaterialFor(net.minecraft.world.entity.Entity entity, net.minecraft.core.BlockPos standingOn, net.minecraft.core.BlockPos standingIn)
    A more rich method of acquiring an appropriate block sound using contextual entity information.
    getMaterialForRaw(net.minecraft.world.level.block.state.BlockState state)
    Return raw, 1:1 bindings from blocks/materials to SpiritMaterials.
    static boolean
    isBlockVanilla(net.minecraft.world.level.block.Block block)
    Returns true if this block is vanilla based on whether or not it is a field in Blocks.
    static boolean
    isMaterialVanilla(net.minecraft.world.level.material.Material material)
    Returns true if this material is vanilla based on whether or not it is a field in Material.
    static void
    setConditionForBlock(net.minecraft.world.level.block.Block block, ISpiritMaterialAcquisitionFunction func)
    Registers a means of applying a custom material to a block via a predicate function.
    static void
    setConditionForMaterial(net.minecraft.world.level.material.Material mtl, ISpiritMaterialAcquisitionFunction func)
    Registers a means of applying a custom material to a different block material via a predicate function.
    static void
    setEffectiveMaterialForRegistryObject(net.minecraftforge.registries.RegistryObject<net.minecraft.world.level.block.Block> block, SpiritMaterial mtl)
    Associates the specific Block (by registry object) with the given SpiritMaterial, which is used to alter its sound to a specific Spirit block material.
    static void
    setOverrideMaterialFor(net.minecraft.world.level.block.Block block, net.minecraft.world.level.material.Material mtl)
    Associates the specific Block with the given Minecraft or Mod Material, which can be used to alter its sound on a material basis.
    static void
    setSpiritMaterialFor(net.minecraft.world.level.block.Block block, SpiritMaterial mtl)
    Associates the specific Block with the given SpiritMaterial, which is used to alter its sound to a specific Spirit block material.
    static void
    setSpiritMaterialForArbitrary(net.minecraft.resources.ResourceLocation loc, SpiritMaterial mtl)
    A sort of concise method of associating a block ID with a SpiritMaterial, which can be used for mods with conditionally registered blocks or blocks from other mods.
    Note: Conditionally registered blocks are considered bad practice by Forge.
    static void
    setSpiritMaterialForState(net.minecraft.world.level.block.state.BlockState state, SpiritMaterial mtl)
    A more concise method that allows associating a specific BlockState to a specific material rather than the entire block type.
    static void
    useIfIn(net.minecraft.resources.ResourceLocation loc)
    Modify the test used for this block's (by ID) material so that its sound is played if the player is inside of this block (as opposed to on top of it).
    static void
    useIfIn(net.minecraft.world.level.block.Block block)
    Modify the test used for this block's material so that its sound is played if the player is inside of this block (as opposed to on top of it).
    static void
    useIfIn(net.minecraft.world.level.block.state.BlockState state)
    Modify the test used for this specific state's material so that its sound is played if the player is inside of this block (as opposed to on top of it).
    static void
    useIfIn(net.minecraftforge.registries.RegistryObject<net.minecraft.world.level.block.Block> block)
    Modify the test used for this registered block's material so that its sound is played if the player is inside of this block (as opposed to on top of it).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getMaterialFor

      public static SpiritMaterial getMaterialFor(net.minecraft.world.entity.Entity entity, net.minecraft.core.BlockPos standingOn, net.minecraft.core.BlockPos standingIn)
      A more rich method of acquiring an appropriate block sound using contextual entity information. Allows checking conditional cases.
      Parameters:
      entity - The entity to test.
      standingOn - The position of the block the entity is standing on.
      standingIn - The position of the block the entity is standing in.
      Returns:
      An appropriate material for the information in the system.
    • getMaterialForRaw

      public static SpiritMaterial getMaterialForRaw(net.minecraft.world.level.block.state.BlockState state)
      Return raw, 1:1 bindings from blocks/materials to SpiritMaterials. Does not work with conditional statements as those require an entity and two BlockStates.
      Parameters:
      state - The state of the block to test.
      Returns:
      The appropriate material for this.
    • getAppropriateMaterialBetween

      public static net.minecraft.world.level.block.state.BlockState getAppropriateMaterialBetween(net.minecraft.world.level.block.state.BlockState blockStandingOn, net.minecraft.world.level.block.state.BlockState blockStandingIn)
      Given two blockstates, this determines which state should be used to grab the material from.
      Parameters:
      blockStandingOn - The block that is being stood on.
      blockStandingIn - The block that is being stood in.
      Returns:
      The appropriate BlockState to use given this material's settings.
    • associateMCMaterialWith

      public static void associateMCMaterialWith(net.minecraft.world.level.material.Material mtl, SpiritMaterial smtl)
      Associates the given Minecraft or Mod Material with the given SpiritMaterial
      Parameters:
      mtl - The Minecraft vanilla material (or custom Mod material) to associate.
      smtl - The Spirit Material to associate it with.
    • setOverrideMaterialFor

      public static void setOverrideMaterialFor(net.minecraft.world.level.block.Block block, net.minecraft.world.level.material.Material mtl) throws IllegalArgumentException
      Associates the specific Block with the given Minecraft or Mod Material, which can be used to alter its sound on a material basis. This is mostly intended for use with modded blocks. Only use this with vanilla blocks if, for whatever reason, you have completely overridden it and it requires unique behavior. This is strictly only useful if the auditory material is different than the block's assigned material.
      Parameters:
      block - The block to associate
      mtl - The material to associate it with.
      Throws:
      IllegalArgumentException - If the block's material is identical to mtl.
    • setSpiritMaterialFor

      public static void setSpiritMaterialFor(net.minecraft.world.level.block.Block block, SpiritMaterial mtl)
      Associates the specific Block with the given SpiritMaterial, which is used to alter its sound to a specific Spirit block material.
      Parameters:
      block - The block to associate.
      mtl - The Spirit material to associate it with.
    • setSpiritMaterialForState

      public static void setSpiritMaterialForState(net.minecraft.world.level.block.state.BlockState state, SpiritMaterial mtl)
      A more concise method that allows associating a specific BlockState to a specific material rather than the entire block type.
      Parameters:
      state - The specific state to associate.
      mtl - The Spirit material to associate it with.
    • setSpiritMaterialForArbitrary

      public static void setSpiritMaterialForArbitrary(net.minecraft.resources.ResourceLocation loc, SpiritMaterial mtl)
      A sort of concise method of associating a block ID with a SpiritMaterial, which can be used for mods with conditionally registered blocks or blocks from other mods.
      Note: Conditionally registered blocks are considered bad practice by Forge. According to Forge, you should simply disable its recipe instead. This can also be used to register blocks from other mods, however it is generally a bad idea to do this unless it is your own mod.
      Parameters:
      loc - The ID of a hypothetical block to associate.
      mtl - The Spirit material to associate it with.
    • setEffectiveMaterialForRegistryObject

      public static void setEffectiveMaterialForRegistryObject(net.minecraftforge.registries.RegistryObject<net.minecraft.world.level.block.Block> block, SpiritMaterial mtl)
      Associates the specific Block (by registry object) with the given SpiritMaterial, which is used to alter its sound to a specific Spirit block material.
      Parameters:
      block - The block to associate.
      mtl - The Spirit material to associate it with.
    • useIfIn

      public static void useIfIn(net.minecraft.world.level.block.Block block)
      Modify the test used for this block's material so that its sound is played if the player is inside of this block (as opposed to on top of it).
      Parameters:
      block - The block to set.
    • useIfIn

      public static void useIfIn(net.minecraft.world.level.block.state.BlockState state)
      Modify the test used for this specific state's material so that its sound is played if the player is inside of this block (as opposed to on top of it).
      Parameters:
      state - The specific block state to set.
    • useIfIn

      public static void useIfIn(net.minecraft.resources.ResourceLocation loc)
      Modify the test used for this block's (by ID) material so that its sound is played if the player is inside of this block (as opposed to on top of it).
      Parameters:
      loc - The ID of a hypothetical block to set.
    • useIfIn

      public static void useIfIn(net.minecraftforge.registries.RegistryObject<net.minecraft.world.level.block.Block> block)
      Modify the test used for this registered block's material so that its sound is played if the player is inside of this block (as opposed to on top of it).
      Parameters:
      block - The registry object of the block to set.
    • setConditionForBlock

      public static void setConditionForBlock(net.minecraft.world.level.block.Block block, ISpiritMaterialAcquisitionFunction func)
      Registers a means of applying a custom material to a block via a predicate function.
      Parameters:
      block - The block to apply the predicate to.
      func - A function that determines which material to use based on the entity's information
    • setConditionForMaterial

      public static void setConditionForMaterial(net.minecraft.world.level.material.Material mtl, ISpiritMaterialAcquisitionFunction func)
      Registers a means of applying a custom material to a different block material via a predicate function.
      Parameters:
      mtl - The material to apply the predicate to.
      func - A function that determines which material to use based on the entity's information
    • isMaterialVanilla

      public static boolean isMaterialVanilla(net.minecraft.world.level.material.Material material)
      Returns true if this material is vanilla based on whether or not it is a field in Material.
      Parameters:
      material - The material to check.
      Returns:
      True if the reference is one present in Material.
    • isBlockVanilla

      public static boolean isBlockVanilla(net.minecraft.world.level.block.Block block)
      Returns true if this block is vanilla based on whether or not it is a field in Blocks.
      Parameters:
      block - The block to check.
      Returns:
      True if the reference is one present in Blocks.