Baubles - roidrole/Roids-Tweaker GitHub Wiki

Allows modifying baubles. Extra methods are available if you use Bubbles

File content :

IPlayer Expansion

Method Parameter Description
getBaublesInventory [None] Returns an IBaublesInventory
getBubblesInventory [None] Only works if you have Bubbles. Returns an IBubbleInventory
isBaubleEquipped bauble as IItemStack Returns an int, which is the bauble's slot number. -1 if not found

IBauble

Import :

import mods.ctintegration.baubles.IBauble;

A class containing useful static methods.

Method Parameter Description
getBaubleType item as IItemStack Returns a string representing the type of the item
getValidSlots type as string Returns an int[] containing the valid slot indexes for this item. Doesn't work with bubbles
createBauble type as string See Turning an existing item into a bauble

IBaublesInventory

Import:

import mods.ctintegration.baubles.IBaubleInventory;
Method Parameters Return Type Description
isItemValidForSlot slot as int, item as IItemStack, entity as IEntityLivingBase bool
isItemValid slot as int, item as IItemStack bool
getSlotCount [None] int Baubles adds 7 bauble slots, but some other mods (like Bring Me The Rings) may add more slots, so always call this method if you are working with rings or trinkets.
getStackInSlot slot as int IItemStack
setStackInSlot slot as int, item as IItemStack void
You can also iterate through a IBaublesInventory for item in IBaubleInventory{doStuff(item);}

IBubbleInventory

Import:

import mods.ctintegration.bubbles.IBubbleInventory;

This class extends IBaublesInventory. All methods from IBaublesInventory are also available to IBubbleInventory.

Method Parameters Return Type Description
growBaubleSlot type as string, amount as int void Adds amount slots to the specified type
shrinkBaubleSlot type as string, amount as int void Removes amount slots to the specified type
setBaubleSlot type as string, amount as int void Sets the amount of slot of this typw to amount
resetBaubleSlots [None] void Resets all bauble slots

Bauble Item Creation

There are two ways to create a bauble item. The first one is creating a custom item and requires contenttweaker. The second one turns an existing item into a bauble and is only available with the bubbles fork.

Creating a custom item

Requires ContentTweaker

To get a BaubleItemRepresentation, call createBaubleItem(string unlocalizedName) on VanillaFactory.

BaubleItemRepresentation extends ItemRepresentation, so all methods that are available to contenttweaker item builders are also available for it.

ZenProperty Function representation Description
String baubleType - must be one of 'AMULET', 'RING', 'BELT', 'TRINKET', 'HEAD', 'BODY', 'CHARM'. If not set it will be defaulted to TRINKET
BaubleEventHandler.CanEquip canEquip function(IItemStack bauble, IEntityLivingBase wearer) Determines whether the bauble can be equipped
BaubleEventHandler.CanUnequip canUnequip function(IItemStack bauble, IEntityLivingBase wearer) Determines whether the bauble can be unequipped
BaubleEventHandler.OnWornTick onWornTick function(IItemStack bauble, IEntityLivingBase wearer) Called on every tick when wearing the bauble
BaubleEventHandler.OnEquipped onEquipped function(IItemStack bauble, IEntityLivingBase wearer) Called when the bauble is equipped
BaubleEventHandler.OnUnequipped onUnequipped function(IItemStack bauble, IEntityLivingBase wearer) Called when the bauble is unequipped
BaubleEventHandler.WillAutoSync willAutoSync function(IItemStack bauble, IEntityLivingBase wearer)
BaubleEventHandler.GetBaubleType getBaubleType function(IItemStack bauble) Note: this takes priority over the baubleType property, if this is set the baubleType will be ignored!

Turning an existing item into a bauble

Requires Bubbles and config:event category.allowCustomBaubles=true

The main class used for this is InjectableBauble. Here is the import :

mods.ctintegration.baubles.InjectableBauble;

You must first get an instance of InjectableBauble via IBauble.createBauble(type as string). Only vanilla bauble types are supported.

You can set the following properties :

Method Parameters Description
setOnWornTick function(stack as IItemStack, entity as IEntityLivingBase) as void Called every tick this is worn. By default, if set to an ArmorItem, this will call onArmorTick. Otherwise, calls the ItemDefinition's onUpdate.
setMainHand bool Sets whether the default onWornTick should consider that the item is in the main hand. Defaults to true.
setOnEquipped function(stack as IItemStack, entity as IEntityLivingBase) as void
setOnUnequipped function(stack as IItemStack, entity as IEntityLivingBase) as void
setCanEquip function(stack as IItemStack, entity as IEntityLivingBase) as bool
setCanUnequip function(stack as IItemStack, entity as IEntityLivingBase) as bool
setWillAutoSync function(stack as IItemStack, entity as IEntityLivingBase) as bool Whether the server should send NBT/damage changes to the client every 10 ticks
setOnDeath function(slot as int, stack as IItemStack, entity as IEntityLivingBase) as string Called when the wearer dies. Should return one of "DEFAULT", "ALWAYS_KEEP", "ALWAYS_DROP", "DESTROY", "CUSTOM"
register item as IItemDefinition Injects this InjectableBauble into the provided ItemDefinition (all ItemStacks will therefore be baubles)