Class CommonTasks
java.lang.Object
net.dillon.dillonlib.task.CommonTasks
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidexecuteIfPlayer(net.minecraft.world.entity.player.Player player, Consumer<net.minecraft.world.entity.player.Player> playerConsumer) Executes a task for aPlayerif they aren't null.static voidexecuteIftLevel(net.minecraft.world.level.Level l, Consumer<net.minecraft.world.level.Level> levelConsumer) Executes a task of the currentLevelif it isn't null.static ListgetEntitiesWithinRange(net.minecraft.world.level.Level world, Class<? extends net.minecraft.world.entity.LivingEntity> entityListOf, net.minecraft.world.entity.LivingEntity startingPoint, List<Integer> xyz, Predicate<? super net.minecraft.world.entity.LivingEntity> selector) static net.minecraft.world.item.ItemStackgetItemBySlot(net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.EquipmentSlot slot) static net.minecraft.world.item.ItemStackgetMainHandStack(net.minecraft.world.entity.player.Player player) static net.minecraft.world.item.ItemStackgetOffHandStack(net.minecraft.world.entity.player.Player player) static booleanstatic booleanhasEnchantment(Predicate<net.minecraft.world.item.ItemStack> validStack, net.minecraft.resources.ResourceKey<net.minecraft.world.item.enchantment.Enchantment> enchantment, net.minecraft.world.item.ItemStack stack) static voidplaySoundFromLiving(net.minecraft.world.entity.LivingEntity living, net.minecraft.sounds.SoundEvent sound, net.minecraft.sounds.SoundSource source) Plays a sound to aLivingEntity.static voidplaySoundFromLiving(net.minecraft.world.entity.LivingEntity living, net.minecraft.sounds.SoundEvent sound, net.minecraft.sounds.SoundSource source, float volume, float pitch) Plays a sound to aLivingEntity, with a custom volume and pitch.static voidSchedules a task (executes afterdelayTicks).static voidsendOverlayMessage(net.minecraft.world.entity.player.Player player, net.minecraft.network.chat.Component message) Sends an overlay message to aPlayer.static voidsendSystemMessage(net.minecraft.world.entity.player.Player player, net.minecraft.network.chat.Component message) Sends a system message to aPlayer.static voidsendUpdateMessage(net.minecraft.world.entity.player.Player player, net.minecraft.network.chat.Component modName, String linkToUpdate, int textColor) Sends a message to the player indicating their mod requires an update.static voidtickTasks(net.minecraft.server.MinecraftServer server) Tick the task delay, and then execute.
-
Constructor Details
-
CommonTasks
public CommonTasks()
-
-
Method Details
-
schedule
Schedules a task (executes afterdelayTicks). -
tickTasks
public static void tickTasks(net.minecraft.server.MinecraftServer server) Tick the task delay, and then execute. -
sendOverlayMessage
public static void sendOverlayMessage(net.minecraft.world.entity.player.Player player, net.minecraft.network.chat.Component message) Sends an overlay message to aPlayer. -
sendSystemMessage
public static void sendSystemMessage(net.minecraft.world.entity.player.Player player, net.minecraft.network.chat.Component message) Sends a system message to aPlayer. -
sendUpdateMessage
public static void sendUpdateMessage(net.minecraft.world.entity.player.Player player, net.minecraft.network.chat.Component modName, String linkToUpdate, int textColor) Sends a message to the player indicating their mod requires an update. -
playSoundFromLiving
public static void playSoundFromLiving(net.minecraft.world.entity.LivingEntity living, net.minecraft.sounds.SoundEvent sound, net.minecraft.sounds.SoundSource source) Plays a sound to aLivingEntity. -
playSoundFromLiving
public static void playSoundFromLiving(net.minecraft.world.entity.LivingEntity living, net.minecraft.sounds.SoundEvent sound, net.minecraft.sounds.SoundSource source, float volume, float pitch) Plays a sound to aLivingEntity, with a custom volume and pitch. -
executeIfPlayer
public static void executeIfPlayer(net.minecraft.world.entity.player.Player player, Consumer<net.minecraft.world.entity.player.Player> playerConsumer) Executes a task for aPlayerif they aren't null. -
executeIftLevel
public static void executeIftLevel(net.minecraft.world.level.Level l, Consumer<net.minecraft.world.level.Level> levelConsumer) Executes a task of the currentLevelif it isn't null. -
getMainHandStack
public static net.minecraft.world.item.ItemStack getMainHandStack(net.minecraft.world.entity.player.Player player) - Returns:
- the player's main hand stack.
-
getOffHandStack
public static net.minecraft.world.item.ItemStack getOffHandStack(net.minecraft.world.entity.player.Player player) - Returns:
- the player's offhand stack.
-
getItemBySlot
public static net.minecraft.world.item.ItemStack getItemBySlot(net.minecraft.world.entity.player.Player player, net.minecraft.world.entity.EquipmentSlot slot) - Returns:
- the item in the given slot.
-
hasEnchantment
public static boolean hasEnchantment(Predicate<net.minecraft.world.item.ItemStack> validStack, net.minecraft.resources.ResourceKey<net.minecraft.world.item.enchantment.Enchantment> enchantment, net.minecraft.world.item.ItemStack stack) - Returns:
- if the stack has an enchantment.
-
hasEffect
- Returns:
- if the stack has a potion component.
-
getEntitiesWithinRange
public static List getEntitiesWithinRange(net.minecraft.world.level.Level world, Class<? extends net.minecraft.world.entity.LivingEntity> entityListOf, net.minecraft.world.entity.LivingEntity startingPoint, List<Integer> xyz, Predicate<? super net.minecraft.world.entity.LivingEntity> selector) - Parameters:
world- level referenceentityListOf- the list of entities to return, by classstartingPoint- the entity that the game should start searching fromxyz- an array of the maximumx, y, and zsearch radius- Returns:
- a raw
Listof entities (excludingnamed entities) within a specified range, and a custom predicate.
-