This mod provides some integration between the mod Set Bonus and CraftTweaker (it requires both of them to work).
See the "Example" section to get an idea of what is possible with this mod. If you find bugs or there is an additional feature you wish to get implemented, let me know in the comments.
/setbonus resetconfig when sets are defined using scripts. This command clears all sets and reloads only the config file, using it will remove the sets added with scripts.Returns true if the player has a given set bonus.
events.onPlayerAttackEntity(function(event as PlayerAttackEntityEvent) {
val attacker = event.player; // IPlayer
val count = attacker.getSetPieceCount("Diamond");
if (attacker.hasSetBonus("diamondFull")){
attacker.sendChat("Has the set bonus!");
}
});
Returns the number of pieces the player has of a given set.
events.onPlayerAttackEntity(function(event as PlayerAttackEntityEvent) {
val attacker = event.player; // IPlayer
val count = attacker.getSetPieceCount("Diamond");
attacker.sendChat("Diamond pieces: " + count);
});
To use the methods to create sets, bonuses and link elements to bonuses (same as the config of Set Bonus) remember to import the class of this addon in the .zs script:
import ctsetbonus.SetTweaks as SB;
Adds a single item to a slot in a set. Creates the set if missing. Adding multiple items to the same slot works as an "or", so the set will accept any of the items added in that slot.
SB.addEquipToSet("Leather", "head", "minecraft:leather_helmet");
Same as above, but with slot index.
SB.addEquipToSet("Leather", 36, "minecraft:leather_boots");
Adds items to a single slot in a set.
val swords = [
"minecraft:wooden_sword",
"minecraft:stone_sword",
"minecraft:iron_sword"
];
SB.addEquipToSet("BladeDancer", "mainhand", swords);
Same, but using the slot index.
val boots = [
"minecraft:leather_boots",
"minecraft:chainmail_boots"
];
SB.addEquipToSet("MixedBoots", 36, boots);
Adds a Full Set as a requirement to a Bonus (with discovery method set to "always visible"). Creates the bonus if missing.
SB.addSetReqToBonus("diamondFull", "Unbreakable poise", "Diamond");
Adds a specific number of items of a Set as a requirement for a Bonus (also with discovery method "always visible").
SB.addSetReqToBonus("iron2pc", "Steadfast", "Iron", 2);
Adds with explicit discovery mode:
0 = hidden until the player has activated the bonus at least once
1 = always visible
2 = always hidden
To require the entire set, use -1 for numberOfParts.
SB.addSetReqToBonus("goldFull", "Gilded vigor", "Gold", -1, 1); // full set, visible
Permanent effect (no interval) at the given amplifier.
SB.addPotionEffectToBonus("leatherFull", "minecraft:speed", 0);
Timed effect with refresh interval (ticks).
SB.addPotionEffectToBonus("chain3pc", "minecraft:strength", 0, 200, 40); // 10s, tick every 2s
Adds an attribute modifier. Operation: "add", "mult_base", "mult_total".
SB.addAttributeModToBonus("diamondFull", "generic.armor", 0.20, "mult_base");
Applies an enchantment to a specific item in the slot using the vanilla enchantment combination behavior.
SB.addEnchantmentToBonus("goldFull", "mainhand", "minecraft:golden_sword", "minecraft:fire_aspect", 1);
Applies an enchantment to a specific item in the slot, with a given mode:
0 = Vanilla enchantment combination behavior
1 = Vanilla behavior, but without limits (can go above max level)
2 = Set the level directly, overriding whatever level it might've had before
3 = Add to the existing level (can be used to subtract from existing level if you put in a negative level number)
4 = Add to existing level, without limits
SB.addEnchantmentToBonus("goldFull", "mainhand", "minecraft:golden_sword", "minecraft:fire_aspect", 1, 4);
Same thing as the previous, but using a String instead of a code.
"vanilla" = Vanilla enchantment combination behavior
"vanilla_unlimited" = Vanilla behavior, but without limits (can go above max level)
"override" = Set the level directly, overriding whatever level it might've had before
"additive" = Add to the existing level (can be used to subtract from existing level if you put in a negative level number)
"additive_unlimited" = Add to existing level, without limits
SB.addEnchantmentToBonus("goldFull", "mainhand", "minecraft:golden_sword", "minecraft:fire_aspect", 1, "vanilla_unlimited");
An example using this mod for registering the armor set and giving 2 custom effects: The player gains flying for a few seconds when dealing damage and deals bonus damage when not touching the ground. The method "asIPlayer" is a custom method that I created, but it is not in this mod, and there might be smarter ways to do that. This example is mostly for you to grasp an idea of what is possible using Craft Tweaker.
import crafttweaker.entity.IEntity;
import crafttweaker.entity.IEntityLivingBase;
import crafttweaker.player.IPlayer;
import crafttweaker.event.EntityLivingHurtEvent;
import ctsetbonus.SetTweaks as SB;
// BALANCING
val damageBonusDealt = 5.0; // magic damage to apply when airborne
val flyTimeSeconds = 2; // flight duration
// NAMES AND DESCRIPTION
val setName = "Valkyrie";
val bonusName = "Valkyrie Set Bonus";
val BonusDescription = "When attacking grants flying for " + (flyTimeSeconds as int) +
"s and deals " + (damageBonusDealt as int) + " bonus damage while airborne.";
SB.addEquipToSet(setName, "head", "aether_legacy:valkyrie_helmet");
SB.addEquipToSet(setName, "chest", "aether_legacy:valkyrie_chestplate");
SB.addEquipToSet(setName, "legs", "aether_legacy:valkyrie_leggings");
SB.addEquipToSet(setName, "feet", "aether_legacy:valkyrie_boots");
SB.addSetReqToBonus(bonusName, BonusDescription, setName);
events.onEntityLivingHurt(function(event as EntityLivingHurtEvent) {
val damageSource = event.damageSource;
val attacker = damageSource.getTrueSource();
if (!(attacker instanceof IPlayer)){
return;
}
val player = attacker.asIPlayer();
if (player.hasSetBonus(bonusName)) {
player.addPotionEffect(<potion:potioncore:flight>.makePotionEffect(flyTimeSeconds * 20, 1));
if (!player.onGround) {
event.amount = event.amount + damageBonusDealt;
}
}
});