ContentTweaker

ContentTweaker

27M Downloads

Example script does not work

sipes42 opened this issue ยท 2 comments

commented

I am attempting to use this script to create a new item in game. It is copied directly from the items section of the wiki.

import mods.contenttweaker.VanillaFactory;
import mods.contenttweaker.Item;
import mods.contenttweaker.IItemRightClick;
import mods.contenttweaker.Commands;

var zsItem = VanillaFactory.createItem("zs_item");
zsItem.maxStackSize = 8;
zsItem.rarity = "rare";
zsItem.creativeTab = zsCreativeTab;
zsItem.smeltingExperience = 10;
zsItem.toolClass = "pickaxe";
zsItem.toolLevel = 5;
zsItem.beaconPayment = true;
zsItem.itemRightClick = function(stack, world, player, hand) {
Commands.call("scoreboard players set @p name 5", player, world);
return "Pass";
};
zsItem.register();

Upon entering a world in-game, the following is displayed in chat:

ERROR: registry.zs:9 > No such static member in mods.contenttweaker.CreativeTab: zsCreativeTab
ERROR: executing registry.zs: null

I have also tried changing zsCreativeTab to other tab names, such as Building_Blocks, but the exact same error appears.

commented

I have also tried this:

import mods.contenttweaker.VanillaFactory;
import mods.contenttweaker.Item;
import mods.contenttweaker.IItemRightClick;
import mods.contenttweaker.Commands;
import mods.contenttweaker.CreativeTab;

var zsCreativeTab = VanillaFactory.createCreativeTab("zs_tab", minecraft:grass);
zsCreativeTab.register();

var zsItem = VanillaFactory.createItem("zs_item");
zsItem.maxStackSize = 8;
zsItem.rarity = "rare";
zsItem.creativeTab = zsCreativeTab;
zsItem.smeltingExperience = 10;
zsItem.toolClass = "pickaxe";
zsItem.toolLevel = 5;
zsItem.beaconPayment = true;
zsItem.itemRightClick = function(stack, world, player, hand) {
Commands.call("scoreboard players set @p name 5", player, world);
return "Pass";
};
zsItem.register();

commented

Fixed in the ContentTweaker version coming out today