DefaultRedstoneWireEvaluator .java

net.minecraft.world.level.redstone.DefaultRedstoneWireEvaluator (class): members: updatePowerStrength, orientation. imports: RedstoneWireBlock, Sets.

net.minecraft.world.level.redstoneclass45 linescommonextends RedstoneWireEvaluator1.5 KB

API Surface (1)

void updatePowerStrength(final Level level, final BlockPos pos, final BlockState state, final @Nullable Orientation orientation, final boolean skipShapeUpdates)

Fields & Constants (1)

orientation

Code Graph: Dependencies (7)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

DefaultRedstoneWireEvaluator.java45 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.redstone;
2
3
import com.google.common.collect.Sets;
4
import java.util.Set;
5
import net.minecraft.core.BlockPos;
6
import net.minecraft.core.Direction;
7
import net.minecraft.world.level.Level;
8
import net.minecraft.world.level.block.RedstoneWireBlock;
9
import net.minecraft.world.level.block.state.BlockState;
10
import org.jspecify.annotations.Nullable;
11
12
public class DefaultRedstoneWireEvaluator extends RedstoneWireEvaluator {
13
	public DefaultRedstoneWireEvaluator(final RedstoneWireBlock wireBlock) {
14
		super(wireBlock);
15
	}
16
17
	@Override
18
	public void updatePowerStrength(
19
		final Level level, final BlockPos pos, final BlockState state, final @Nullable Orientation orientation, final boolean skipShapeUpdates
20
	) {
21
		int targetStrength = this.calculateTargetStrength(level, pos);
22
		if (state.getValue(RedstoneWireBlock.POWER) != targetStrength) {
23
			if (level.getBlockState(pos) == state) {
24
				level.setBlock(pos, state.setValue(RedstoneWireBlock.POWER, targetStrength), 2);
25
			}
26
27
			Set<BlockPos> toUpdate = Sets.newHashSet();
28
			toUpdate.add(pos);
29
30
			for (Direction direction : Direction.values()) {
31
				toUpdate.add(pos.relative(direction));
32
			}
33
34
			for (BlockPos blockPos : toUpdate) {
35
				level.updateNeighborsAt(blockPos, this.wireBlock);
36
			}
37
		}
38
	}
39
40
	private int calculateTargetStrength(final Level level, final BlockPos pos) {
41
		int blockSignal = this.getBlockSignal(level, pos);
42
		return blockSignal == 15 ? blockSignal : Math.max(blockSignal, this.getIncomingWireSignal(level, pos));
43
	}
44
}
45

Decompiled Minecraft 26.3 source of DefaultRedstoneWireEvaluator (net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java) with Mojang official mappings, stored verbatim on the site.