Class ActiveConfig
java.lang.Object
com.hammy275.immersivemc.common.config.ActiveConfig
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
ClientActiveConfig
-
Field Summary
Modifier and TypeFieldDescriptionboolean
boolean
boolean
static final ActiveConfig
static int
static ClientActiveConfig
static ActiveConfig
static ActiveConfig
protected static final com.google.gson.Gson
protected static final com.google.gson.Gson
int
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ClientActiveConfig
active()
Get the ActiveConfig for the client.static ClientActiveConfig
Gets the ACTIVE config.clone()
static ActiveConfig
decode
(net.minecraft.network.FriendlyByteBuf buffer) Decodes a buffer into a (Client)ActiveConfig instance.protected <T> T
defaultIfNull
(T val, T def) void
encode
(net.minecraft.network.FriendlyByteBuf buffer) Encodes this ActiveConfig instance into the buffer.protected <T extends Enum<T>>
TfirstEnumIfNull
(T val, Class<T> clazz) static ActiveConfig
getActiveConfigCommon
(net.minecraft.world.entity.player.Player player) static ClientActiveConfig
getConfigForPlayer
(net.minecraft.world.entity.player.Player player) Get the ActiveConfig for a player.static ActiveConfig
getFileConfig
(ConfigType type) static void
Set ACTIVE config to be the merge of the FILE config and the FROM_SERVER config if connected to a server.static void
Loads DISABLED config into the ACTIVE slot.static void
Loads the configs from the config files.void
mergeWithServer
(ActiveConfig other) Merges this config with the config provided.static ActiveConfig
readConfigFile
(ConfigType type) static void
registerPlayerConfig
(net.minecraft.world.entity.player.Player player, ClientActiveConfig config) Register config for playervoid
Sets this config to its disabled form.void
Modifies the config to ensure all values are within valid ranges.boolean
writeConfigFile
(ConfigType type)
-
Field Details
-
DISABLED
-
FILE_SERVER
-
FILE_CLIENT
-
FROM_SERVER
-
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
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
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
-
readConfigFile
-
writeConfigFile
-
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
-
mergeWithServer
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
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
-
firstEnumIfNull
-
defaultIfNull
protected <T> T defaultIfNull(T val, T def)
-