ContentTweaker

ContentTweaker

27M Downloads

[Feature]: Conditional Checks && Alterations-Based on Checks

Lanse505 opened this issue ยท 0 comments

commented

New Additions:
Cause:
world.checkAdjacentBlockState:

//Checks Adjecent Blocks and can be checked for a true/false value
Example.onBlockBreak = function(world, blockPosXYZ, blockState) {
    world.checkAdjacentBlockState(<block:minecraft:dirt>, blockState.offset(north, 1), blockState.offset(south, 1), blockState.offset(west, 1), blockState.offset(east, 1), blockState.offset(up, 1), blockState.offset(down, 1)) == True {
    	world.setDrops(<item:ExampleMod:DirtiedBerries>)
    }
};

player.isEquipped && isEquippedBauble

//Checks if a specific item is Equipped and can be checked for a true/false value (Works with Baubles)
Example.onBlockBreak = function(player, world, blockPos, blockState) {
	player.isEquipped(<item:minecraft:iron_helmet>, player) == false{
		player.addEffect(<effect:XYZ>);
	}
};

Example.onBlockBreak = function(player, world, blockPos, blockState) {
	player.isEquippedBauble(<item:ExampleMod:ExampleBauble>, player) == false{
		player.addEffect(<effect:XYZ>);
	}
};

player.hasNBT:

//Checks if a player has a specific NBT-tag, can be checked for a true/false value
Example.onBlockBreak = function(player, world, blockPos, blockState) {
	player.hasNBT(<tag:level:30>) == true {
		world.setDrops(<item:ExampleMod:ExampleItem>)
	}
};

world.worldCondition (weather, light, blockState, break

//Checks if a World Condition is true, can be checked for a true/false value
Example.onBlockBreak = function(world, blockPos, blockState) {
	world.worldCondition(<light:15>) == true {
		world.setDrops(<item:ExampleMod:ExampleItem>)
	}
};

Example.onBlockBreak = function(world, blockPos, blockState) {
	world.worldCondition(<blockState:3>) == true {
		world.setDrops(<item:ExampleMod:ExampleItem>)
	}
};

Example.onBlockBreak = function(world, blockPos, blockState) {
	world.worldCondition(<break:player>) == true {
		world.setDrops(<item:ExampleMod:ExampleItem>)
	}
};

Example.onBlockBreak = function(world, blockPos, blockState) {
	world.worldCondition(<break:nonPlayer>) == true {
		world.setDrops(<item:ExampleMod:ExampleItem>)
	}
};

world.wasBrokenBy:

//Checks what item was used to break the block, can be checked for a true/false value
Example.onBlockBreak = function(world, blockPosXYZ, blockState) {
	world.wasBrokenBy(<item:minecraft:stick>) == True {
		world.setDrops(<item:ExampleMod:ExampleItem>)
	}
};

Effects:
player.addEffect:
See isEquipped && isEquippedBauble Examples Above