Raycast constructor

Raycast(
  1. Entity entity, {
  2. int? max,
  3. double step = 1,
  4. Block through = Blocks.air,
  5. Widget ray(
    1. Function,
    2. Function
    )?,
  6. List<Widget> onhit = const [],
  7. String scoreName = 'objd_count',
})

The Raycast Widget is one of the most powerful widgets by giving you many options to configure raycasting in Minecraft. Internally it uses local coordinates, a distance counter and recursion.

constructor
Entity from which entity to go from
onhit a List of Widgets that execute on a hit
max maximum block distance(optional)
step how many steps to go forward each iteration(default = 1)
through a Block or Blocktag with passable Blocks(default = air)
ray a Function with an interface for each iteration(optional)
scoreName option to specify counter score(default = objd_count)

Example:

Raycast(
	Entity.All(),
	onhit: [
		SetBlock(Blocks.sandstone,location:Location.here())
	],
	ray: (stop, hit) => If(...,then:[stop()]),
	max: 10, // set maximum distance to 10 blocks
	step: 0.1,
	through: Block('#minecraft:transparent'),
)

Implementation

Raycast(
  this.entity, {
  this.max,
  this.step = 1,
  this.through = Blocks.air,
  this.ray,
  this.onhit = const [],
  this.scoreName = 'objd_count',
});