Class ActiveConfig

java.lang.Object
com.hammy275.immersivemc.common.config.ActiveConfig
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
ClientActiveConfig

public class ActiveConfig extends Object implements Cloneable
  • Field Details

    • DISABLED

      public static final ActiveConfig DISABLED
    • FILE_SERVER

      public static ActiveConfig FILE_SERVER
    • FILE_CLIENT

      public static ClientActiveConfig FILE_CLIENT
    • FROM_SERVER

      public static ActiveConfig FROM_SERVER
    • fields

      public static List<Field> fields
    • fieldsHash

      public static int fieldsHash
    • GSON

      protected static final com.google.gson.Gson GSON
    • GSON_PRETTY

      protected static final com.google.gson.Gson GSON_PRETTY
    • useAnvilImmersive

      public boolean useAnvilImmersive
    • useBrewingStandImmersive

      public boolean useBrewingStandImmersive
    • useChestImmersive

      public boolean useChestImmersive
    • useCraftingTableImmersive

      public boolean useCraftingTableImmersive
    • useFurnaceImmersive

      public boolean useFurnaceImmersive
    • useJukeboxImmersive

      public boolean useJukeboxImmersive
    • useRangedGrabImmersive

      public boolean useRangedGrabImmersive
    • useButtonImmersive

      public boolean useButtonImmersive
    • useEnchantingTableImmersive

      public boolean useEnchantingTableImmersive
    • useCampfireImmersive

      public boolean useCampfireImmersive
    • useLeverImmersive

      public boolean useLeverImmersive
    • useBagImmersive

      public boolean useBagImmersive
    • useRepeaterImmersive

      public boolean useRepeaterImmersive
    • useDoorImmersive

      public boolean useDoorImmersive
    • useTrapdoorImmersive

      public boolean useTrapdoorImmersive
    • allowPetting

      public boolean allowPetting
    • useArmorImmersive

      public boolean useArmorImmersive
    • useFeedingAnimalsImmersive

      public boolean useFeedingAnimalsImmersive
    • useShulkerImmersive

      public boolean useShulkerImmersive
    • allowPettingAnythingLiving

      public boolean allowPettingAnythingLiving
    • useShieldImmersive

      public boolean useShieldImmersive
    • rangedGrabRange

      public int rangedGrabRange
    • useBeaconImmersive

      public boolean useBeaconImmersive
    • useBarrelImmersive

      public boolean useBarrelImmersive
    • useThrowingImmersive

      public boolean useThrowingImmersive
    • allowThrowingBeyondVanillaMaxRange

      public boolean allowThrowingBeyondVanillaMaxRange
    • useHopperImmersive

      public boolean useHopperImmersive
    • useSmithingTableImmersive

      public boolean useSmithingTableImmersive
    • useChiseledBookshelfImmersive

      public boolean useChiseledBookshelfImmersive
    • useWrittenBookImmersive

      public boolean useWrittenBookImmersive
    • useCauldronImmersive

      public boolean useCauldronImmersive
    • useIronFurnacesFurnaceImmersive

      public boolean useIronFurnacesFurnaceImmersive
    • useTinkersConstructCraftingStationImmersive

      public boolean useTinkersConstructCraftingStationImmersive
    • useLecternImmersive

      public boolean useLecternImmersive
    • useBucketAndBottleImmersive

      public boolean useBucketAndBottleImmersive
  • Constructor Details

    • ActiveConfig

      public ActiveConfig()
  • Method Details

    • getConfigForPlayer

      public static ClientActiveConfig getConfigForPlayer(net.minecraft.world.entity.player.Player player)
      Get the ActiveConfig for a player. For server only!
      Parameters:
      player - Player to get config of.
      Returns:
      Config for player, or a disabled config if the player does not have a config.
    • active

      public static ClientActiveConfig active()
      Get the ActiveConfig for the client. For client only!
      Returns:
      Config for the local player, or a disabled config if not in VR and the setting to disable ImmersiveMC outside VR is enabled.
    • activeRaw

      public static ClientActiveConfig activeRaw()
      Gets the ACTIVE config. For client only, and should only be used for changing the values in the active config. All other methods should use active().
      Returns:
      The ACTIVE config.
    • registerPlayerConfig

      public static void registerPlayerConfig(net.minecraft.world.entity.player.Player player, ClientActiveConfig config)
      Register config for player
      Parameters:
      player - Player to register config for.
      config - Config from the player.
    • getFileConfig

      public static ActiveConfig getFileConfig(ConfigType type)
    • readConfigFile

      public static ActiveConfig readConfigFile(ConfigType type)
    • writeConfigFile

      public boolean writeConfigFile(ConfigType type)
    • loadActive

      public static void loadActive()
      Set ACTIVE config to be the merge of the FILE config and the FROM_SERVER config if connected to a server. Should only be called by the client.
    • loadDisabled

      public static void loadDisabled()
      Loads DISABLED config into the ACTIVE slot.
    • getActiveConfigCommon

      public static ActiveConfig getActiveConfigCommon(net.minecraft.world.entity.player.Player player)
    • mergeWithServer

      public void mergeWithServer(ActiveConfig other)
      Merges this config with the config provided. This will only update values that both the client and server get a say in (Synced values). For example, both the server and the client can declare useAnvilImmersion to be false. If at least one of them declares it such, it will be false in this instance after merging. For values only one side gets a say in (C2S synced values and Non-synced values), the value in this instance will not change. The values in the other config will never change.
      Parameters:
      other - The other config
    • setDisabled

      public void setDisabled()
      Sets this config to its disabled form.
    • loadFilesToMemory

      public static void loadFilesToMemory()
      Loads the configs from the config files.
    • encode

      public void encode(net.minecraft.network.FriendlyByteBuf buffer)
      Encodes this ActiveConfig instance into the buffer.
      Parameters:
      buffer - Buffer to encode into.
    • decode

      public static ActiveConfig decode(net.minecraft.network.FriendlyByteBuf buffer)
      Decodes a buffer into a (Client)ActiveConfig instance.
      Parameters:
      buffer - Buffer to decode from.
    • validateConfig

      public void validateConfig()
      Modifies the config to ensure all values are within valid ranges.
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • firstEnumIfNull

      protected <T extends Enum<T>> T firstEnumIfNull(T val, Class<T> clazz)
    • defaultIfNull

      protected <T> T defaultIfNull(T val, T def)