ContentTweaker

ContentTweaker

27M Downloads

Equality operators only check IF a block has metadata, not if metadata matches

superfluke opened this issue ยท 0 comments

commented

Since the equality operators are backwards in this version, if(blocky != <block:minecraft:wool:6>) returns true when a player clicks on pink wool. However, it also returns true when a player clicks on orange/purple/red wool. It does return false when a player clicks on white wool. So it seems the if statement is returning true as long as the wool block click on has any metadata rather than checking specifically for the metadata 6.

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

Expected: give player gold block when right clicking on pink wool and shrink item stack
Actual: give player gold block when right clicking on any colored wool and shrinking item stack
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();