Skip to content

Instantly share code, notes, and snippets.

@Davi-zzz
Created June 3, 2026 03:07
Show Gist options
  • Select an option

  • Save Davi-zzz/b5d9f1f0a7b7ea4fb6796f7b05a0399e to your computer and use it in GitHub Desktop.

Select an option

Save Davi-zzz/b5d9f1f0a7b7ea4fb6796f7b05a0399e to your computer and use it in GitHub Desktop.
kubejs-sample.js
var JsonIO = Java.loadClass("dev.latvian.mods.kubejs.util.JsonIO");
var EquipmentSlot = Java.loadClass("net.minecraft.world.entity.EquipmentSlot");
ServerEvents.recipes(function (event) {
var exported = [];
Item.getList().forEach(function (item) {
try {
var stack = Item.of(String(item.id));
if (stack.empty) return;
var attributes = {};
var slotsParaChecar = [EquipmentSlot.MAINHAND, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET, EquipmentSlot.HEAD];
// Acumuladores para validação do filtro
var danoTotal = 0;
var armorTotal = 0;
slotsParaChecar.forEach(function (slot) {
try {
var modifiers = stack.item.getDefaultAttributeModifiers(slot);
if (!modifiers.isEmpty()) {
modifiers.asMap().forEach(function (attribute, modifierCollection) {
var attrKey = String(attribute.descriptionId);
if (!attributes[attrKey]) {
attributes[attrKey] = [];
}
modifierCollection.forEach(function (modifier) {
var numeroLimpo = Math.round(modifier.amount * 100) / 100;
attributes[attrKey].push({
amount: numeroLimpo,
operation: String(modifier.operation),
});
// Soma o dano se for o atributo de ataque
if (attrKey === "attribute.name.generic.attack_damage") {
danoTotal += modifier.amount;
}
// Soma a armadura se for o atributo de defesa
if (attrKey === "attribute.name.generic.armor") {
armorTotal += modifier.amount;
}
});
});
}
} catch (e) {}
});
// FILTRO DUPLO: Só passa se (Dano > 9) OU (Armor > 8)
if (danoTotal <= 9 && armorTotal <= 8) {
return;
}
// Define o tipo dinamicamente baseado no maior atributo encontrado
var type = "item";
if (danoTotal > 9) {
type = "weapon";
} else if (armorTotal > 8) {
type = "equipment";
}
exported.push({
id: String(stack.id),
name: String(stack.hoverName.string),
type: type,
attributes: attributes
});
} catch (e) {
console.error("Erro geral no item " + item.id + ": " + e);
}
});
try {
JsonIO.write('C:/minecraft/exported_equipment.json', exported);
console.log("Sucesso! Arquivo filtrado (Dano > 9 ou Armor > 8) exportado para C:/minecraft/exported_equipment.json");
} catch (err) {
console.log(JSON.stringify(exported));
}
});
const ids = [
"iceandfire:dragonsteel_lightning_axe",
"soulsweapons:withered_chest",
"iceandfire:dragonsteel_lightning_chestplate",
"iceandfire:troll_weapon_column_frost",
"iceandfire:dragonsteel_lightning_leggings",
"iceandfire:dragonsteel_fire_chestplate",
"iceandfire:dragonsteel_fire_shovel",
"soulsweapons:nightfall",
"soulsweapons:shadow_assassin_scythe",
"iceandfire:troll_weapon_trunk_frost",
"iceandfire:armor_green_leggings",
"paladins:aeternium_mace",
"soulsweapons:darkin_scythe",
"paladins:aeternium_claymore",
"iceandfire:dragonsteel_fire_leggings",
"soulsweapons:enhanced_arkenplate",
"mythicmetals:hallowed_axe",
"iceandfire:armor_amethyst_leggings",
"iceandfire:tide_trident",
"iceandfire:dragonsteel_fire_pickaxe",
"herbalbrews:jug",
"iceandfire:dragonsteel_ice_shovel",
"betternether:flaming_ruby_axe",
"iceandfire:troll_weapon_trunk",
"mythicmetals:hallowed_chestplate",
"soulsweapons:forlorn_scythe",
"mythicmetals:adamantite_axe",
"paladins:iron_great_hammer",
"paladins:ruby_claymore",
"iceandfire:dread_queen_sword",
"soulsweapons:arkenplate",
"iceandfire:armor_blue_leggings",
"paladins:ruby_great_hammer",
"iceandfire:dragonsteel_ice_chestplate",
"mythicmetals:red_aegis_sword",
"iceandfire:dragonsteel_lightning_shovel",
"iceandfire:dragonsteel_ice_pickaxe",
"iceandfire:dread_knight_sword",
"soulsweapons:enhanced_withered_chest",
"iceandfire:dragonsteel_ice_sword",
"iceandfire:troll_weapon_hammer",
"iceandfire:armor_bronze_leggings",
"mythicmetals:metallurgium_sword",
"mythicmetals:orichalcum_chestplate",
"betterend:aeternium_axe",
"iceandfire:dragonsteel_lightning_sword",
"iceandfire:armor_gray_leggings",
"betterend:aeternium_chestplate",
"iceandfire:troll_weapon_column_forest",
"iceandfire:armor_white_leggings",
"iceandfire:dragonsteel_fire_axe",
"iceandfire:armor_sapphire_leggings",
"iceandfire:dragonsteel_lightning_pickaxe",
"iceandfire:armor_silver_leggings",
"soulsweapons:pure_moonlight_greatsword",
"paladins:diamond_great_hammer",
"mythicmetals:celestium_axe",
"iceandfire:troll_weapon_column",
"mythicmetals:metallurgium_pickaxe",
"paladins:netherite_claymore",
"paladins:diamond_claymore",
"paladins:ruby_mace",
"mythicmetals:orichalcum_hammer",
"iceandfire:armor_copper_leggings",
"soulsweapons:soul_reaper",
"iceandfire:dragonsteel_ice_leggings",
"iceandfire:armor_red_leggings",
"iceandfire:armor_black_leggings",
"iceandfire:ghost_sword",
"betterend:aeternium_hammer",
"iceandfire:troll_weapon_axe",
"soulsweapons:darkin_blade",
"iceandfire:dragonsteel_ice_axe",
"mythicmetals:metallurgium_chestplate",
"iceandfire:dragonsteel_fire_sword",
"mythicmetals:metallurgium_axe",
"paladins:netherite_mace",
"soulsweapons:supernova",
"paladins:aeternium_great_hammer",
"paladins:netherite_great_hammer",
"mythicmetals:celestium_chestplate",
"soulsweapons:frostmourne",
"iceandfire:armor_electric_leggings"
]
LootJS.modifiers((event) => {
var bausAlvo = [
"minecraft:chests/end_city_treasure",
"minecraft:chests/bastion_treasure",
"minecraft:chests/ancient_city",
"minecraft:chests/stronghold_corridor",
"minecraft:chests/nether_bridge"
];
ids.forEach(function (equip) {
event.addLootModifier(bausAlvo)
.randomChance(0.02)
.addLoot(equip.id);
});
console.log("[LootJS] Sucesso! " + ids.length + " itens lendários injetados nos baús.");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment