ParallaxLib - Parallax Studios 模组的核心库
即将推出更新,请耐心等待。
ParallaxLib 是 Parallax Studios 旗下所有模组的共享库,旨在通过集中核心功能来简化开发流程并提升性能。
? 为什么使用 ParallaxLib?
? 更快的开发速度 – 提供共享代码,减少我们各个模组间的冗余。
? 无缝集成 – 允许其他 Parallax Studios 模组之间无缝协作(即将推出!)
? 高效的数据处理 – 存储玩家属性如生命值、饥饿值、药水效果和物品栏数据,以便我们的模组快速访问。
PotionHandler 文档
如何将 PotionHandler 导入你的项目
import me.parallax.PotionHandler;
PotionHandler 是你用于在 Minecraft Forge 模组中轻松向实体施加药水效果的实用工具类。它会根据名称映射所有已注册的 MobEffect,因此你只需通过字符串名称即可应用效果——无需到处引用原始的 MobEffect 实例。
工作原理 — 基础
效果注册表:
PotionHandler 在静态代码块中自动构建一个从所有已注册药水效果名称(如 "speed"、"strength" 等)到对应 MobEffect 实例的映射。
获取效果:
MobEffect speedEffect = PotionHandler.getEffect("speed");
应用单个效果:
// entity = 某个 LivingEntity(玩家、生物等)
// duration 以刻为单位(20 刻 = 1 秒)
// amplifier = 药水等级 - 1(因此 0 代表 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);
API 详解
public static MobEffect getEffect(String name)
- 输入:药水效果名称(不区分大小写,例如 "speed"、"fire_resistance"、"haste")。
- 返回:对应的 MobEffect,如果未找到则返回 null。
public static void applyEffect(LivingEntity entity, String effectName, int durationTicks, int amplifier, boolean showParticles, boolean isAmbient)
- 根据名称向指定实体施加药水效果。
- 参数:
entity: 需要增益/减益的实体。
effectName: 效果的字符串名称。
durationTicks: 效果持续的时长,单位为刻(20 刻 = 1 秒)。
amplifier: 效果强度等级减一(0 = 1 级,1 = 2 级,依此类推)。
showParticles: 是否显示药水粒子效果。
isAmbient: 是否为环境效果(通常信标等效果为 true)。
- 如果效果名称未知,将在控制台打印错误信息。
public static void applyEffects(LivingEntity entity, List<MobEffectInstance> effects)
- 将一组 MobEffectInstance 列表应用于实体。
- 如果你已经准备好了 MobEffectInstance,这个方法非常方便。
? ItemIDGet 文档 ?️
欢迎使用 ItemIDGet 文档!这个实用工具类是你获取 Minecraft 模组中物品 ID 和命名空间信息的得力助手。无论你是处理 ItemStack 还是纯物品 ID 字符串,这个类都能帮你迅速获取所需信息。?
✨ 如何使用 ItemIDGet ✨
要开始使用 ItemIDGet,你需要将其导入项目中。别担心,这很简单!只需在文件顶部添加以下内容:
import me.parallax.ItemIDGet;
?️ 可用方法 ?️
- getId(ItemStack stack) ?
描述:获取 ItemStack 的完整物品 ID。
用法:传入一个 ItemStack,获取作为字符串的物品 ID。
示例:
ItemStack stack = new ItemStack(Items.DIAMOND_SWORD);
String itemId = ItemIDGet.getId(stack);
System.out.println(itemId); // 输出: minecraft:diamond_sword
- getNamespace(ItemStack stack) ?
描述:从 ItemStack 获取物品的命名空间。
用法:传入一个 ItemStack,获取命名空间(如 minecraft、modid 等)。
示例:
String namespace = ItemIDGet.getNamespace(stack);
System.out.println(namespace); // 输出: minecraft
? 如何检查模组是否已加载 ?
如果你想检查游戏中是否加载了某个特定模组,可以使用 isModLoaded 方法。
isModLoaded(String modid) ⚙️
描述:检查指定 ID 的模组是否已加载。
用法:传入模组 ID 作为字符串(例如 "minecraft")。
示例:
boolean isLoaded = ItemIDGet.isModLoaded("minecraft");
System.out.println(isLoaded); // 输出: true 或 false
? 关键注意事项
重要提示:ItemIDGet 设计用于直接处理物品 ID(例如 minecraft:diamond_block),但我们还添加了一个方法来处理 ItemStack。如果你只有字符串,则无需使用 ItemStack。?
如果你在处理模组,还可以使用 isModLoaded() 方法来检查它们是否已加载!?
? 结语
就是这样!? ItemIDGet 是一个方便的工具,可简化在 Minecraft 模组中检索物品信息的流程。无论你是处理 ItemStack 对象还是只需要快速查找物品 ID,这个类都能满足你的需求。?
欢迎在你的模组中使用它,如有任何问题请随时告知。祝制作愉快!?
如果某个 Parallax Studios 模组明确列出 ParallaxLib 作为依赖项或其描述中提到 ParallaxLib,则意味着该模组运行必需 ParallaxLib。
ParallaxLib - The Core Library for Parallax Studios Mods
An update is coming soon, please bare with us.
ParallaxLib is a shared library for all mods developed by Parallax Studios, designed to streamline development and enhance performance by centralizing essential features.
? Why Use ParallaxLib?
? 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.
PotionHandler Documentation
How to import PotionHandler into your project
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.
How it works — the basics
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");
Apply one effect:
// 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);
Apply multiple effects:
List<MobEffectInstance> effects = List.of(
new MobEffectInstance(PotionHandler.getEffect("speed"), 300, 2),
new MobEffectInstance(PotionHandler.getEffect("jump_boost"), 300, 1)
);
PotionHandler.applyEffects(entity, effects);
API breakdown
public static MobEffect getEffect(String name)
- Input: Potion effect name (case-insensitive, e.g. "speed", "fire_resistance", "haste").
- Returns: The corresponding MobEffect or null if not found.
public static void applyEffect(LivingEntity entity, String effectName, int durationTicks, int amplifier, boolean showParticles, boolean isAmbient)
- Applies a potion effect by name to the given entity.
- Parameters:
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.).
- If the effect name is unknown, prints an error to console.
public static void applyEffects(LivingEntity entity, List<MobEffectInstance> effects)
- Apply a list of MobEffectInstances to an entity.
- Handy if you already have MobEffectInstances prepared.
? ItemIDGet Documentation ?️
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 ?️
- getId(ItemStack stack) ?
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
- getNamespace(ItemStack stack) ?
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.
评论 0
登录后参与评分
还没有评论,来抢沙发吧