package net.mcreator.puzzle_code.procedures;

import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.core.Direction;

public class LeftTransferLogicCodeBlockUpdateTickProcedure {
	public static void execute(LevelAccessor world, double x, double y, double z, BlockState blockstate) {
		Direction blockDirection = Direction.NORTH;
		if (!GetNBTLogicSystemProcedure.execute(world, x, y, z, "isDisabled")) {
			blockDirection = new Object() {
				public Direction getDirection(BlockState _bs) {
					Property<?> _prop = _bs.getBlock().getStateDefinition().getProperty("facing");
					if (_prop instanceof DirectionProperty _dp)
						return _bs.getValue(_dp);
					_prop = _bs.getBlock().getStateDefinition().getProperty("axis");
					return _prop instanceof EnumProperty _ep && _ep.getPossibleValues().toArray()[0] instanceof Direction.Axis ? Direction.fromAxisAndDirection((Direction.Axis) _bs.getValue(_ep), Direction.AxisDirection.POSITIVE) : Direction.NORTH;
				}
			}.getDirection(blockstate);
			SetNBTLogicSystemProcedure.execute(world, GetXOffsetSystemProcedure.execute(x, blockDirection, "Left"), GetYOffsetSystemProcedure.execute(y, blockDirection, "Left"), GetZOffsetSystemProcedure.execute(z, blockDirection, "Left"),
					GetNBTLogicSystemProcedure.execute(world, GetXOffsetSystemProcedure.execute(x, blockDirection, "Back"), GetYOffsetSystemProcedure.execute(y, blockDirection, "Back"), GetZOffsetSystemProcedure.execute(z, blockDirection, "Back"),
							GetNBTTextSystemProcedure.execute(world, x, y, z, "getNBT")),
					GetNBTTextSystemProcedure.execute(world, x, y, z, "setNBT"));
		}
	}
}
