作者:rebot | 分类:模组
Minecraft 版本: 1.19.2
平台: forge
标签: library
ParallaxLib is a shared library for all mods developed by Parallax Studios, designed to streamline development and enhance performance by centralizing essential features.
? Faster Development – Provides shared code, reducing redundancy across our mods.
? Seamless Integration – Allows other Parallax Studios mods to work together seamlessly (coming soon!)
? Efficient Data Handling – Stores player stats like health, food, potion stats, and inventory for quick access by our mods.
import me.parallax.PotionHandler;
PotionHandler is your go-to utility class for easily applying potion effects to entities in Minecraft Forge mods. It maps all registered MobEffects by name, so you can apply them simply by string name — no need to keep referencing the raw MobEffect instances everywhere.
Effect registry:
PotionHandler internally builds a map from all registered potion effect names (like "speed", "strength", etc.) to their corresponding MobEffect instances. This happens automatically in the static block.
Get an effect:
MobEffect speedEffect = PotionHandler.getEffect("speed");
// entity = some LivingEntity (player, mob, etc.)
// duration in ticks (20 ticks = 1 second)
// amplifier = potion level - 1 (so 0 means level 1)
PotionHandler.applyEffect(entity, "strength", 200, 1, true, false);
List<MobEffectInstance> effects = List.of(
new MobEffectInstance(PotionHandler.getEffect("speed"), 300, 2),
new MobEffectInstance(PotionHandler.getEffect("jump_boost"), 300, 1)
);
PotionHandler.applyEffects(entity, effects);
entity: The entity to buff/debuff.effectName: The string name of the effect.durationTicks: How long the effect lasts, in ticks (20 ticks = 1 second).amplifier: Effect strength level minus one (0 = level 1, 1 = level 2, etc.).showParticles: Whether the potion particles show.isAmbient: Whether the effect is ambient (usually true for beacons, etc.).Welcome to the ItemIDGet documentation! This utility class is your go-to tool for retrieving item IDs and namespace information in Minecraft mods. Whether you're working with an ItemStack or a plain item ID string, this class can help you get the information you need in no time. ?
✨ How to Use ItemIDGet ✨
To get started with ItemIDGet, you'll need to import it into your project. Don't worry, it's simple! Just add this at the top of your file:
import me.parallax.ItemIDGet;
?️ Methods Available ?️
Description: Get the full item ID for an ItemStack.
Usage: Pass an ItemStack and get the item ID as a string.
Example:
ItemStack stack = new ItemStack(Items.DIAMOND_SWORD);
String itemId = ItemIDGet.getId(stack);
System.out.println(itemId); // Output: minecraft:diamond_sword
Description: Get the namespace of the item from an ItemStack.
Usage: Pass an ItemStack and get the namespace (like minecraft, modid, etc.).
Example:
String namespace = ItemIDGet.getNamespace(stack);
System.out.println(namespace); // Output: minecraft
? How to Check if a Mod is Loaded ?
If you want to check if a certain mod is loaded in the game, you can use the isModLoaded method.
isModLoaded(String modid) ⚙️
Description: Checks if a mod with the specified ID is loaded.
Usage: Pass the mod ID as a string (e.g., "minecraft").
Example:
boolean isLoaded = ItemIDGet.isModLoaded("minecraft");
System.out.println(isLoaded); // Output: true or false
? Key Notes
Important: ItemIDGet is designed to work with direct Item IDs (ex. minecraft:diamond_block), but we've also added a method to handle ItemStacks. No need for ItemStack if you just have the string though. ?
If you're working with mods, you can also check if they're loaded with the isModLoaded() method! ?
? Conclusion
That's all! ? ItemIDGet is a handy tool to simplify the process of retrieving item information in Minecraft mods. Whether you're working with ItemStack objects or just need a quick item ID lookup, this class has you covered. ?
Feel free to use this in your own mods, and let us know if you have any questions. Happy modding! ?
If a Parallax Studios mod specifically lists ParallaxLib as a dependency or anywhere in its description, it means ParallaxLib is REQUIRED for that mod to operate.
请登录后举报
暂无评论,抢个沙发吧~