Class Helpers

java.lang.Object
net.darkhax.botanypots.common.impl.Helpers

public class Helpers extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<net.minecraft.world.level.block.Block>
     
    static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,net.minecraft.world.level.block.state.BlockState>
     
    static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,net.minecraft.world.level.block.Block>
     
    static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block>>
     
    static final com.mojang.serialization.Codec<net.minecraft.world.entity.EntityType<?>>
     
    static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,net.minecraft.world.entity.EntityType<?>>
     
    static final Supplier<net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute>>
     
    static final String
     
    static final net.minecraft.tags.TagKey<net.minecraft.world.item.enchantment.Enchantment>
     
    static final com.mojang.serialization.Codec<net.minecraft.world.item.Item>
     
    static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,net.minecraft.world.item.Item>
     
    static final net.minecraft.tags.TagKey<net.minecraft.world.item.enchantment.Enchantment>
     
    static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,Optional<net.minecraft.advancements.critereon.BlockPredicate>>
     
    static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,Optional<net.minecraft.world.item.crafting.Ingredient>>
     
    static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,Optional<net.minecraft.world.item.ItemStack>>
     
    static final Supplier<net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute>>
     
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    chanceToInt(float chance)
     
    static boolean
    contains(String input, String... matches)
     
    static int
    determineRollCount(float chance, net.minecraft.util.RandomSource rng)
    Calculates the amount of rolls that should take place.
    static float
    efficiencyModifier(net.minecraft.core.RegistryAccess registryAccess, net.minecraft.world.item.ItemStack stack)
     
    static double
    getAttributeValue(net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> attribute, net.minecraft.world.item.ItemStack stack, float defaultValue)
     
    static int
    getLootRolls(BotanyPotContext context, net.minecraft.world.level.Level level, Crop crop, @Nullable Soil soil)
     
    static int
    getRequiredGrowthTicks(BotanyPotContext context, net.minecraft.world.level.Level level, Crop crop, @Nullable Soil soil)
     
    static float
    getTotalYield(BotanyPotContext context, net.minecraft.world.level.Level level, Crop crop, @Nullable Soil soil)
     
    static net.minecraft.network.chat.Component
    indent(net.minecraft.network.chat.Component base)
     
    static net.minecraft.network.chat.Component
    modifierComponent(String key, float modifier)
     
    static net.minecraft.network.chat.MutableComponent
    withScale(net.minecraft.network.chat.MutableComponent base, float scale)
     

    Methods inherited from class java.lang.Object

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

    • BLOCK_CODEC

      public static final com.mojang.serialization.Codec<net.minecraft.world.level.block.Block> BLOCK_CODEC
    • BLOCK_STREAM

      public static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,net.minecraft.world.level.block.Block> BLOCK_STREAM
    • ITEM_CODEC

      public static final com.mojang.serialization.Codec<net.minecraft.world.item.Item> ITEM_CODEC
    • ITEM_STREAM

      public static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,net.minecraft.world.item.Item> ITEM_STREAM
    • ENTITY_TYPE_CODEC

      public static final com.mojang.serialization.Codec<net.minecraft.world.entity.EntityType<?>> ENTITY_TYPE_CODEC
    • ENTITY_TYPE_STREAM

      public static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,net.minecraft.world.entity.EntityType<?>> ENTITY_TYPE_STREAM
    • BLOCK_STATE_STREAM

      public static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,net.minecraft.world.level.block.state.BlockState> BLOCK_STATE_STREAM
    • OPTIONAL_INGREDIENT_STREAM

      public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,Optional<net.minecraft.world.item.crafting.Ingredient>> OPTIONAL_INGREDIENT_STREAM
    • OPTIONAL_ITEMSTACK_STREAM

      public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,Optional<net.minecraft.world.item.ItemStack>> OPTIONAL_ITEMSTACK_STREAM
    • OPTIONAL_BLOCK_PREDICATE

      public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,Optional<net.minecraft.advancements.critereon.BlockPredicate>> OPTIONAL_BLOCK_PREDICATE
    • BLOCK_TAG

      public static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,net.minecraft.tags.TagKey<net.minecraft.world.level.block.Block>> BLOCK_TAG
    • INCREASE_POT_GROWTH_TAG

      public static final net.minecraft.tags.TagKey<net.minecraft.world.item.enchantment.Enchantment> INCREASE_POT_GROWTH_TAG
    • NEGATE_HARVEST_DAMAGE_TAG

      public static final net.minecraft.tags.TagKey<net.minecraft.world.item.enchantment.Enchantment> NEGATE_HARVEST_DAMAGE_TAG
    • GROWTH_MOD_ATTRIBUTE

      public static final Supplier<net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute>> GROWTH_MOD_ATTRIBUTE
    • GROWTH_MODIFIER_KEY

      public static final String GROWTH_MODIFIER_KEY
      See Also:
    • YIELD_MOD_ATTRIBUTE

      public static final Supplier<net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute>> YIELD_MOD_ATTRIBUTE
    • YIELD_MODIFIER_KEY

      public static final String YIELD_MODIFIER_KEY
      See Also:
  • Constructor Details

    • Helpers

      public Helpers()
  • Method Details

    • modifierComponent

      public static net.minecraft.network.chat.Component modifierComponent(String key, float modifier)
    • indent

      public static net.minecraft.network.chat.Component indent(net.minecraft.network.chat.Component base)
    • getRequiredGrowthTicks

      public static int getRequiredGrowthTicks(BotanyPotContext context, net.minecraft.world.level.Level level, Crop crop, @Nullable @Nullable Soil soil)
    • getTotalYield

      public static float getTotalYield(BotanyPotContext context, net.minecraft.world.level.Level level, Crop crop, @Nullable @Nullable Soil soil)
    • getLootRolls

      public static int getLootRolls(BotanyPotContext context, net.minecraft.world.level.Level level, Crop crop, @Nullable @Nullable Soil soil)
    • determineRollCount

      public static int determineRollCount(float chance, net.minecraft.util.RandomSource rng)
      Calculates the amount of rolls that should take place. When chance is over 100% there will be a guaranteed roll for each multiple of 100% plus an additional random chance using the remainder. The amount of rolls determined will never be negative.

      For example, if the chance is 550% the user will have 5 guaranteed rolls and a 50% chance for a sixth roll.

      Parameters:
      chance - The chance for rolls to happen.
      rng - An RNG source used to calculate percentages.
      Returns:
      The amount of rolls that was determined. Can never be negative.
    • chanceToInt

      public static int chanceToInt(float chance)
    • withScale

      public static net.minecraft.network.chat.MutableComponent withScale(net.minecraft.network.chat.MutableComponent base, float scale)
    • efficiencyModifier

      public static float efficiencyModifier(net.minecraft.core.RegistryAccess registryAccess, net.minecraft.world.item.ItemStack stack)
    • getAttributeValue

      public static double getAttributeValue(net.minecraft.core.Holder<net.minecraft.world.entity.ai.attributes.Attribute> attribute, net.minecraft.world.item.ItemStack stack, float defaultValue)
    • contains

      public static boolean contains(String input, String... matches)