Class Helpers
java.lang.Object
org.cyclops.integrateddynamics.core.helper.Helpers
Helper methods.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.google.common.base.Predicate<net.minecraft.world.entity.Entity> static final net.minecraft.nbt.TagParser<net.minecraft.nbt.Tag> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddInterfaceRetriever(Helpers.IInterfaceRetriever interfaceRetriever) static doublecalculateTps(long[] times) static StringcapitalizeString(String value) Return a string with the first character capitalized.static StringcreatePatternOfLength(int length) Create a string of 'length' times '%s' seperated by ','.static Stream<net.minecraft.world.level.block.state.BlockState> getBlockTagValues(String name) Retrieves a Stream of blocks that are registered to this tag name.static net.neoforged.neoforge.fluids.FluidStackgetFluidStack(net.minecraft.world.item.ItemStack itemStack) Get the fluidstack from the given itemstack.static intgetFluidStackCapacity(net.minecraft.world.item.ItemStack itemStack) Get the fluidstack capacity from the given itemstack.static Stream<net.neoforged.neoforge.fluids.FluidStack> getFluidTagValues(String name) Retrieves a Stream of fluids that are registered to this tag name.static <C> Optional<C> getInterface(org.cyclops.cyclopscore.datastructure.DimPos dimPos, Class<C> clazz, boolean forceLoad) Check for the given interface at the given position.static net.minecraft.network.chat.ComponentgetLocalizedEnergyLevel(int stored, int capacity) Get a localized string showing the ratio of stored energy vs the capacity.static Stream<net.minecraft.world.item.ItemStack> getTagValues(String name) Retrieves a Stream of items that are registered to this tag name.static <T> List<T> Add the given element to a copy of the given list/static longmean(long[] values) static voidreturnItemToPlayer(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack itemStack) static <T extends Exception,R>
R
-
Field Details
-
SELECTOR_IS_PLAYER
public static final com.google.common.base.Predicate<net.minecraft.world.entity.Entity> SELECTOR_IS_PLAYER -
TAG_PARSER
public static final net.minecraft.nbt.TagParser<net.minecraft.nbt.Tag> TAG_PARSER
-
-
Constructor Details
-
Helpers
public Helpers()
-
-
Method Details
-
getFluidStack
public static net.neoforged.neoforge.fluids.FluidStack getFluidStack(net.minecraft.world.item.ItemStack itemStack) Get the fluidstack from the given itemstack.- Parameters:
itemStack- The itemstack.- Returns:
- The fluidstack or null.
-
getFluidStackCapacity
public static int getFluidStackCapacity(net.minecraft.world.item.ItemStack itemStack) Get the fluidstack capacity from the given itemstack.- Parameters:
itemStack- The itemstack.- Returns:
- The capacity
-
getTagValues
public static Stream<net.minecraft.world.item.ItemStack> getTagValues(String name) throws net.minecraft.ResourceLocationException Retrieves a Stream of items that are registered to this tag name.- Parameters:
name- The tag name- Returns:
- A Stream containing ItemStacks registered for this tag
- Throws:
net.minecraft.ResourceLocationException
-
getBlockTagValues
public static Stream<net.minecraft.world.level.block.state.BlockState> getBlockTagValues(String name) throws net.minecraft.ResourceLocationException Retrieves a Stream of blocks that are registered to this tag name.- Parameters:
name- The tag name- Returns:
- A Stream containing Blocks registered for this tag
- Throws:
net.minecraft.ResourceLocationException
-
getFluidTagValues
public static Stream<net.neoforged.neoforge.fluids.FluidStack> getFluidTagValues(String name) throws net.minecraft.ResourceLocationException Retrieves a Stream of fluids that are registered to this tag name.- Parameters:
name- The tag name- Returns:
- A Stream containing Fluids registered for this tag
- Throws:
net.minecraft.ResourceLocationException
-
joinList
Add the given element to a copy of the given list/- Type Parameters:
T- The type.- Parameters:
list- The list.newElement- The element.- Returns:
- The new joined list.
-
createPatternOfLength
Create a string of 'length' times '%s' seperated by ','.- Parameters:
length- The length for the series of '%s'.- Returns:
- The string.
-
getInterface
public static <C> Optional<C> getInterface(org.cyclops.cyclopscore.datastructure.DimPos dimPos, Class<C> clazz, boolean forceLoad) Check for the given interface at the given position.- Type Parameters:
C- The class type.- Parameters:
dimPos- The dimensional position.clazz- The class to find.forceLoad- If the world should be loaded if it was not loaded yet.- Returns:
- The optional instance.
-
getLocalizedEnergyLevel
public static net.minecraft.network.chat.Component getLocalizedEnergyLevel(int stored, int capacity) Get a localized string showing the ratio of stored energy vs the capacity.- Parameters:
stored- The stored amount of energy.capacity- The capacity of the energy container.- Returns:
- The localized string.
-
calculateTps
public static double calculateTps(long[] times) -
mean
public static long mean(long[] values) -
addInterfaceRetriever
-
capitalizeString
Return a string with the first character capitalized.- Parameters:
value- A string.- Returns:
- A capitalized string.
-
returnItemToPlayer
public static void returnItemToPlayer(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack itemStack) -
sneakyThrow
- Throws:
T
-