Package etithespirit.orimod
Class GeneralUtils
java.lang.Object
etithespirit.orimod.GeneralUtils
A set of general utilities that the mod may or may not use.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
A value that can be passed into packed light parameters to indicate full brightness.static final boolean
True if this is the development environment and false if this is the live game. -
Method Summary
Modifier and TypeMethodDescriptionstatic net.minecraft.client.player.LocalPlayer
Client only.static String
getModName
(String modid) Given a mod's ID, this will attempt to locate the mod's user-friendly display name through Forge's mod list.static net.minecraft.resources.ResourceLocation
getResourceLocation
(net.minecraft.world.level.block.Block block) static boolean
hasAllFlags
(int value, int flag) Returns true if(value & flag) == flag
(or,value
has the bits defined byflag
all set to 1).static boolean
hasAnyFlag
(int value, int flag) Returns true if(value & flag) > 0
(or,value
has at least one of the bits defined byflag
set to 1).static boolean
isClient
(net.minecraft.world.entity.Entity entityIn) Returns whether or not this entity exists on the client side by checking its world.static boolean
isClient
(net.minecraft.world.level.Level worldIn) The most reliable and the best way to acquire the side, this checks the isRemote status of the input world.static boolean
static boolean
This will still return true on an integrated server or LAN server.static boolean
Client only.static boolean
isServer
(net.minecraft.world.entity.Entity entityIn) Returns whether or not this entity exists on the server side by checking its world.static boolean
isServer
(net.minecraft.world.level.Level worldIn) The most reliable and the best way to acquire the side, this checks the isRemote status of the input world.static void
Shows text at the bottom of the screen like when a new item is equipped.
-
Field Details
-
IS_DEV_ENV
public static final boolean IS_DEV_ENVTrue if this is the development environment and false if this is the live game. -
FULL_BRIGHT_LIGHT
public static final int FULL_BRIGHT_LIGHTA value that can be passed into packed light parameters to indicate full brightness. Lightmaps are a UV graph of two short values packed as an int- See Also:
-
-
Method Details
-
getResourceLocation
public static net.minecraft.resources.ResourceLocation getResourceLocation(net.minecraft.world.level.block.Block block) -
getModName
Given a mod's ID, this will attempt to locate the mod's user-friendly display name through Forge's mod list. Throws an exception if the mod couldn't be found.- Parameters:
modid
- The ID of the mod to locate, or "minecraft"- Returns:
- The user-friendly display name associated with the mod ID.
- Throws:
NoSuchElementException
- If no mod was found with that ID.
-
isPlayerViewingDebugMenu
public static boolean isPlayerViewingDebugMenu()Client only. Whether or not the local player is showing the debug menu (F3)- Returns:
- Whether or not the local player is showing the debug menu (F3)
-
getLocalPlayer
public static net.minecraft.client.player.LocalPlayer getLocalPlayer()Client only. Alias method to get the instance of the local player.- Returns:
- A reference to the local player.
-
isGameClient
public static boolean isGameClient()This will still return true on an integrated server or LAN server.- Returns:
true
if this build of the game is the playable client.
-
isDedicatedServer
public static boolean isDedicatedServer()- Returns:
true
if this build of the game is the dedicated server build.
-
isClient
public static boolean isClient(net.minecraft.world.level.Level worldIn) The most reliable and the best way to acquire the side, this checks the isRemote status of the input world.- Parameters:
worldIn
- The world to test.- Returns:
- True if the world is clientside, false if it is not.
-
isServer
public static boolean isServer(net.minecraft.world.level.Level worldIn) The most reliable and the best way to acquire the side, this checks the isRemote status of the input world.- Parameters:
worldIn
- The world to test.- Returns:
- True if the world is serverside, false if it is not.
-
isClient
public static boolean isClient(net.minecraft.world.entity.Entity entityIn) Returns whether or not this entity exists on the client side by checking its world.- Parameters:
entityIn
- The entity to use to acquire the side.- Returns:
- True if the given entity exists on the server.
-
isServer
public static boolean isServer(net.minecraft.world.entity.Entity entityIn) Returns whether or not this entity exists on the server side by checking its world.- Parameters:
entityIn
- The entity to use to acquire the side.- Returns:
- True if the given entity exists on the server.
-
hasAllFlags
public static boolean hasAllFlags(int value, int flag) Returns true if(value & flag) == flag
(or,value
has the bits defined byflag
all set to 1).- Parameters:
value
- The value to test.flag
- The bits of value that should be equal to 1.- Returns:
- Whether or not the given value has the given bits set (as defined in flag)
-
hasAnyFlag
public static boolean hasAnyFlag(int value, int flag) Returns true if(value & flag) > 0
(or,value
has at least one of the bits defined byflag
set to 1).- Parameters:
value
- The value to test.flag
- The bits of value that should be equal to 1.- Returns:
- Whether or not the given value has at least one of the given bits set (as defined in flag)
-
message
@ServerUseOnly public static void message(net.minecraft.server.level.ServerPlayer player, String message) Shows text at the bottom of the screen like when a new item is equipped.- Parameters:
player
- The player to show it for.message
- The message to display.
-