player.sendChat Sends message to chat twice
superfluke opened this issue ยท 1 comments
Got a few errors on the same sample item here, gonna break it up into the separate bugs, lemme know if you'd prefer them combined next time.
In a single player world.
base-1.12.2-3.6.1.jar
ContentTweaker-1.12.2-4.4.1
Forge 14.23.2.2611
Test item should print 'Hello darkness my old friend' once when you click on any block other than pink wool. However, it seems to send the chat message twice.
Test item code:
var woolkiller = VanillaFactory.createItem("woolkiller");
woolkiller.maxStackSize = 1;
woolkiller.setMaxDamage(10);
woolkiller.onItemUse = function(player, world, pos, hand, facing, blockHit) {
var blocky = world.getBlockState(pos);
if(blocky != <block:minecraft:wool:6>){
var cmdstr = "give " ~ player.name ~ " minecraft:gold_block";
print(cmdstr);
Commands.call(cmdstr, player, world, false, true);
world.setBlockState(<block:minecraft:air>, pos);
player.getHeldItem(hand).shrink(1);
}
else {
player.sendChat("Hello darkness my old friend");
player.getHeldItem(hand).damage(1, player);
}
return ActionResult.success();
};
woolkiller.register();