MC百科社群

标题: 关于CoT构建特性修改匠魂工具面板数据的求助 [打印本页]

作者: cffm    时间: 2024-4-13 14:53
标题: 关于CoT构建特性修改匠魂工具面板数据的求助
[spoiler=脚本]
#priority 2
#loader contenttweaker

import mods.contenttweaker.Color;
import mods.contenttweaker.tconstruct.Material;
import mods.contenttweaker.tconstruct.MaterialBuilder;
import mods.contenttweaker.tconstruct.Trait;
import mods.contenttweaker.tconstruct.TraitBuilder;
import mods.tconstruct.traits.Update;
import crafttweaker.entity.Attribute;
import crafttweaker.entity.AttributeModifier;
import crafttweaker.entity.IEntityEquipmentSlot;
import crafttweaker.player.IPlayer;
import crafttweaker.item.IItemStack;
import crafttweaker.data.IData;
/*
function getItemCertainNBT(item as IItemStack, nbtString as string) as IData {
    if(!isNull(item)&&!isNull(nbtString)&&!isNull(item.tag)&&!isNull(item.tag.memberGet(nbtString))) {
        return item.tag.memberGet(nbtString);
    }
    else return null;
}
*/
var fractured2 = TraitBuilder.create("fractured2");
fractured2.color = 0x002dcf;
fractured2.maxLevel = 1;
fractured2.localizedName = "碎骨II";
fractured2.localizedDescription = "测试";
fractured2.onUpdate = function(trait, tool, world, owner, itemSlot, isSelected) {
    var thistool as IItemStack = tool;
    CotTicLib.addTicAttack(thistool, 3.0f, "cb3f55d3-645c-4f38-a497-9c13a33db5cf");
    //thetool.addGlobalAttributeModifier("generic.attackDamage", IEntityEquipmentSlot.mainHand(), AttributeModifier.createModifier("generic.attackDamage", 3.0, 0, "cb3f55d3-645c-4f38-a497-9c13a33db5cf"), true);
    //thetool.mutable().updateTag({Starts: {Attack: damage}});
};
fractured2.register();

var mutationalbone as MaterialBuilder = MaterialBuilder.create("mutationalbone");
mutationalbone.color = 0x7e7272;
mutationalbone.craftable = true;
mutationalbone.localizedName = "突变骨头";
mutationalbone.representativeItem = <item:contenttweaker:mutationalbone>;
mutationalbone.addItem(<item:contenttweaker:mutationalbone>);
mutationalbone.addHeadMaterialStats(500, 6, 5.5f, 2);
mutationalbone.addHandleMaterialStats(1.2, 100);
mutationalbone.addExtraMaterialStats(130);
mutationalbone.addMaterialTrait("splintering", "head");
mutationalbone.addMaterialTrait("fractured2");
//mutationalbone.addMaterialTrait("alien");
mutationalbone.itemLocalizer = function(thisMaterial, itemName) {
    return "突变骨头 " + itemName;
};
mutationalbone.register();
[/spoiler]
我最近尝试用cot构建像匠魂原版碎骨一样的特性(+1.5面板伤害,我想要碎骨II,即+3面板伤害),先尝试了修改Attribute,成功后发现匠魂武器不吃原版Attribute,而是由NBT内的数据决定伤害,于是又研究NBT修改未果,今天得到回复后尝试使用cot为匠魂添加复杂特性事例 - [CoT]ContentTweaker - MC百科|最大的Minecraft中文MOD百科 (mcmod.cn)中的方法,但是拥有这个特性的物品进入物品栏就会导致崩溃,原因是java.lang.IllegalStateException: GhostItemStack not yet initialized!,遂走投无路来这里请教。希望各位神仙能提出修改意见或者提供实例,拜托了

(上次发帖没人理我qwq)





欢迎光临 MC百科社群 (https://bbs.mcmod.cn/) MC百科|最大的MineCraft中文模组百科